plotly

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

最后都变了- 提交于 2019-12-01 14:49:04
问题 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,

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

末鹿安然 提交于 2019-12-01 14:36:39
问题 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. 回答1: In Julia 1.0, there are two ways to install a package. First, you can do using Pkg Pkg.add("Packagename") Second, you can use the Pkg REPL mode by pressing ] (similar to ? , help mode, and ; , shell

Plotly in R: format axis - tick labels to percentage

最后都变了- 提交于 2019-12-01 14:19:55
问题 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. 回答1: 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

Python dynamic objects not defined anywhere? (Plotly lib)

﹥>﹥吖頭↗ 提交于 2019-12-01 13:42:23
I'm no python expert, but know about programming in general. I've started using https://github.com/plotly/plotly.py/ for doing charts in python but I'm finding problems with 1) getting IDE autocomplete to work and 2) exploring the api (particularly because of 1). One particular thing I dont understand is how this even works: from plotly.graph_objs import * traces = [] traces.append(Scatter( x=val.x, y=val.y, name=str(key), error_y=dict( type='data', array=val.err, visible=True, width=1, ) )) plotly.offline.plot(traces, filename='basic-line.html', auto_open=False) I went to the graph_objs

Error plotting chart with facet_wrap and scales = “free” in plotly

谁都会走 提交于 2019-12-01 13:23:43
I have a time series with various categories (facets), and I am trying to create a chart using the facet_wrap feature from ggplot2 and upload it on plotly . If I set scales = "fixed" , I have no problem: the graph looks fine on my computer and on plotly . But if I set scales = "free" , as in the code below, then the ggplot2 on my computer looks fine, but the plotly version is not showing up properly (either on my computer or the web). Here is some sample code; I create some random values for 12 states covering a 16-year period from 2000 to 2015, and I want to plot a time series of those values

Download a dynamic plotly graph using dynamic downloadHandler() from a shiny app

我只是一个虾纸丫 提交于 2019-12-01 12:21:49
I have the shiny app below from which Im trying to download the plotly graph through downloadHandler() . The issue is that the object that Im trying to download is either a datatable or a plotly plot so I do not know how to pass it to the downloadHandler() . Note that my download button is dynamic as well because in the first case it should download a table and in the second a plot. Note that I care just for the plot here.Open the app in browser.Firstly I install: library(webshot) install_phantomjs() and then: library(shiny) library(plotly) d <- data.frame(X1 = rnorm(50,mean=50,sd=10), X2 =

How do I link a shiny action button to a plotly animation in R?

99封情书 提交于 2019-12-01 11:59:34
I am trying to trigger an animation of a plotly graph with a shiny action button. The animation is done with the use of frames in plotly. However, this creates an automatic play button that triggers the animation. I don't want this button to exist and, instead, I want to trigger the animation with a shiny action button I created. I have tried, unsuccessfully, using the plotlyProxy with the plotlyProxyInvoke("animate") function. p <- plot_ly(sinusoid, x = ~time, y = ~sin, type = "scatter", mode = 'line', colors = colorRampPalette(brewer.pal(5,"Spectral"))(50), hoverinfo = 'none', name = "Cycle"

Python dynamic objects not defined anywhere? (Plotly lib)

≯℡__Kan透↙ 提交于 2019-12-01 11:37:04
问题 I'm no python expert, but know about programming in general. I've started using https://github.com/plotly/plotly.py/ for doing charts in python but I'm finding problems with 1) getting IDE autocomplete to work and 2) exploring the api (particularly because of 1). One particular thing I dont understand is how this even works: from plotly.graph_objs import * traces = [] traces.append(Scatter( x=val.x, y=val.y, name=str(key), error_y=dict( type='data', array=val.err, visible=True, width=1, ) ))

How to generate a custom color scale for plotly heatmap in R

喜夏-厌秋 提交于 2019-12-01 11:12:45
I would like to get a custom color scale which looks like for plotly heatmap ( plot_ly(z = data, colors = customcolors, type = "heatmap") ) palette <- colorRampPalette(c("darkblue", "blue", "lightblue1", "green","yellow", "red", "darkred")) plot(rep(1,50),col=palette(50), pch=19, cex=3, xlab = "", ylab ="", axes = F) and where the blue end represents 1 and red end represents 10^6 and plotted data would have varying values on this interval. The code you use to generate a color palette works just fine. You only need to provide data that match with a heatmap . The following code provides this:

Change comma and thousand separator in tick labels

天大地大妈咪最大 提交于 2019-12-01 08:31:26
In a chart like the one below I wan to change the thousand separator to a dot ".", but I don't know how to use the tickformat parameter in order to get it. require(plotly) p <- plot_ly(x=~c(2012,2013,2014,2015,2016), y=~c(1200000,975000,1420000,1175000,1360000), type='bar') %>% layout(yaxis = list(title="Income in €", tickformat=",d", gridcolor = "#bbb"), xaxis = list(title="Year"), margin=list(l=80)) p As far as I know if you use tickformat , separators gets ignored. So you can either specify your tickformat or your separators . require(plotly) p <- plot_ly(x=~c(2012, 2013, 2014, 2015, 2016),