plotly

Stacked Area Chart in Plot.ly and R

孤街醉人 提交于 2019-12-01 22:24:37
Plot.ly has a tutorial on this for Python: # Add original data x=['Winter', 'Spring', 'Summer', 'Fall'] y0_org=[40, 80, 30, 10] y1_org=[20, 10, 10, 10] y2_org=[40, 10, 60, 80] # Add data to create cumulative stacked values y0_stck=y0_org y1_stck=[y0+y1 for y0, y1 in zip(y0_org, y1_org)] y2_stck=[y0+y1+y2 for y0, y1, y2 in zip(y0_org, y1_org, y2_org)] R doesn't seem to have any similar tutorial. I tried to play with the filled area plot tutorial for R, but failed to build a stacked plot. library(plotly) p <- plot_ly(x = c(1, 2, 3, 4), y = c(0, 2, 3, 5), fill = "tozeroy") add_trace(p, x = c(1, 2

How to specify camera perspective of 3d plotly chart in R?

泪湿孤枕 提交于 2019-12-01 21:10:23
I would like to change the default camera perspective of my plotly 3d scatter plot, it is not clear from the help how this should be done. I understand the layout parameters should be included in a named list but cannot get it to work for the 'eye' 'up' and 'center' camera parameters. https://plot.ly/r/reference/#layout-scene-camera It should be something like: require(plotly) scene=list(bgcolor='#990055',camera=list(eye=c(1,2,3))) plot_ly(x=rnorm(100), y=rnorm(100), z=rnorm(100), type="scatter3d", mode='markers+lines') %>% layout(scene=scene) This is a little late but hopefully this helps

R Plotly: how to order pie chart?

落爺英雄遲暮 提交于 2019-12-01 21:06:18
I'm using the plotly package in R to build an R Shiny dashboard. I want to order my pie chart in a custom order (non-alphabetic, non-descending/ascending order). For some reason I can't find how to achieve this. Help would be highly appreciated! # Get Manufacturer mtcars$manuf <- sapply(strsplit(rownames(mtcars), " "), "[[", 1) df <- mtcars %>% group_by(manuf) %>% summarize(count = n()) # Create custom order customOrder <- c(df$manuf[12:22],df$manuf[1:11]) # Order data frame df <- df %>% slice(match(customOrder, manuf)) # Create factor df$manuf <- factor(df$manuf, levels = df[["manuf"]]) #

How to rotate the dial in a gauge chart? Using python plotly

自作多情 提交于 2019-12-01 21:00:53
I am recently into using plotly package for a gauge chart in python. After going through the tutorial and template here , I wonder if there is a way to rotate the "dial" or "needle" given a angle value? Someone has suggested me using css: transform to do the trick, but still it's hard for me to know how to apply css to the plotly script. A short and simple code would be great. Thank you in advance. A bit late to this question. My solution to this problem, though it still needs work is: I was using the svg path for the dial given in the plotly tutorial, namely M 0.235 0.5 L 0.24 0.65 L 0.245 0

Plotly.js Choropleth map size

被刻印的时光 ゝ 提交于 2019-12-01 20:31:19
I'm trying to make a choropleth map, but how can I set the size of the map? Now I've this map: I would like expand the map to all the space, I read the documentations but I didn't find a solution. This is my code: var data = [{ type: 'choropleth', locationmode: 'country names', locations: unpack(output, 'label'), z: unpack(output, 'nres'), text: unpack(output, 'nres') }]; var layout = { geo: { projection: { type: 'equirectangular' } } }; Plotly.plot(mapChoropleth, data, layout, { showLink: false }); Plotly tries to take all the available space without changing the image ratio. If you have a

ggplotly: log argument cancels axis labels

前提是你 提交于 2019-12-01 19:06:05
问题 I just discovered the newish ggplotly function that makes ggplot2 graphs into interactive plotly visualizations. This is great. But I also ran into an odd effect, possibly a bug. If I use the log= argument to change the axis scales, the axis labels disappear. log="x" will cause the x axis label to disappear, log="y" will cause the y axis label to disappear, and log="xy" will cause both to disappear. The same thing happens if I use scale_x_log10() and scale_y_log10() functions instead of the

ggplotly: log argument cancels axis labels

∥☆過路亽.° 提交于 2019-12-01 18:38:16
I just discovered the newish ggplotly function that makes ggplot2 graphs into interactive plotly visualizations. This is great. But I also ran into an odd effect, possibly a bug. If I use the log= argument to change the axis scales, the axis labels disappear. log="x" will cause the x axis label to disappear, log="y" will cause the y axis label to disappear, and log="xy" will cause both to disappear. The same thing happens if I use scale_x_log10() and scale_y_log10() functions instead of the log argument. Is there a workaround for this? Example (y axis label is visible, x axis label disappears)

Plotly in R: format axis - tick labels to percentage

感情迁移 提交于 2019-12-01 16:30:19
I am creating bar charts in plotly with y-axis representing percentages or shares within 0-1. The y-axis displays as 0.05 instead of 5.0%. Is there a way to display y-axis tick labels as %## ? I have tried using tickformat = "%" but that doesn't seem to be working. You can do this in plotly using layout : p <- p %>% layout(yaxis = list(tickformat = "%")) Or if you want to only add % and do not reformat the numbers then: p <- p %>% layout(yaxis = list(ticksuffix = "%")) Example: This is an example that shows how to edit the y axis ticks as you wish. (like multiply by a number and add suffix,

plotly js: how to run my javascript ONLY after plot image is loaded

旧城冷巷雨未停 提交于 2019-12-01 15:57:54
When using a plotly graph of any sort with the Javascript API (plotly.js, not plotly-nodejs), how can I run some javascript ONLY after the graph has loaded? I'm looking for the mechanism in the plotly javascript API that, for example, does the same thing that 'addListenerOnce', in conjunction with 'tilesloaded' or 'ready', do when using the Google Maps API. For example, let's say I want to simply display an alert immediately after rendering the example shown at https://plot.ly/~PlotBot/685 , for which the html and js code can be seen at https://plot.ly/~PlotBot/685.js . There are many reasons

How to install a package in Julia 1.0 (UndefVarError: Pkg not defined)

狂风中的少年 提交于 2019-12-01 14:59:20
I installed Julia 1.0, and want to make a simple plot. The first step is to type this on Julia: Pkg.add("PyPlot") However, an error occurs: ERROR: UndefVarError: Pkg not defined. The same thing happens when I type: Pkg.status() What's the best way to install a package in Julia? I use MacOS. In Julia 1.0, there are two ways to install a package. First, you can do using Pkg Pkg.add("Packagename") or you can use the Pkg REPL mode by pressing ] (similar to ? , help mode, and ; , shell mode): (v1.0) pkg> add Packagename You can find more information here: https://docs.julialang.org/en/stable/stdlib