plotly

Plotly.js create a point on click

好久不见. 提交于 2019-12-31 05:51:19
问题 Having an issue. Using plotly.js to draw a scatter chart, I need to be able to click on the chart and retrieve the values of the point so that I can draw a new point at the clicked location. The plotly_click event only fires on already created points. Any ideas how I can get a click event to get the current values from the location so I can plot the new point? So far I'm only getting this: var trace1 = { x: [1, 2, 3, 4], y: [10, 15, 13, 17], mode: 'markers', type: 'scatter' }; var trace2 = {

Plotly xaxis in weekday name

て烟熏妆下的殇ゞ 提交于 2019-12-31 04:57:56
问题 I’ve looked into the documentation but they didn’t seem to mention it. https://plot.ly/python/axes/ How can I change the label on x axis to show “Mon 20-7”, “Tue 21-7”, etc. The 'date' used for xaxis is in the format "20-7-2018 11:00:00am", etc. I use the following Python Plotly script: trace0=go.Scatter(x=df_pre.index,y=df_pre['Total'],line=dict(color=('rgb(16,25,109)'),width=1),name='Period_1') trace1=go.Scatter(x=df_post.index,y=df_post['Total'],line=dict(color=('rgb(77,221,26)'),width=2)

Strange formatting of legend in ggplotly in R

混江龙づ霸主 提交于 2019-12-31 03:46:11
问题 I'm trying to turn a ggplot into a plotly. The ggplot renders fine, but when I put it through ggplotly, suddenly the legend adds parenthesis and ",1" after the label. Here's a sample fake data: sorted1<-data.frame(CommDate=c(as.Date("2017-09-12"), as.Date("2017-10-15")), CommName=c("Foo", "Bar"), PubB4=c(2,3)) And here's the code I'm trying to run on it: ggplotly(ggplot(sorted1, aes(x=as.Date(CommDate), y=PubB4))+ geom_smooth(level=0.0, aes(colour="Moving average"), se=FALSE)+ geom_point(aes

Using RequireJS to load plotly and D3

落爺英雄遲暮 提交于 2019-12-31 02:16:08
问题 I am trying to use RequireJS to load the plotly and d3 libraries in my js code. I have tried this: require.config({ paths: { d3: '/static/scripts/plotly/dependencies/d3.v3.min', plotly: '/static/scripts/plotly/plotly.min' } }); require(['d3'], function(d3) { d3(); }); require(['plotly'], function(plotly) { plotly(); }); But this doesn't work. When my js function is called I get: Uncaught ReferenceError: plotly is not defined Uncaught ReferenceError: Plotly is not defined Uncaught

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

烂漫一生 提交于 2019-12-30 23:14:14
问题 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=

How to avoid duplicate legend labels in plotly or pass custom legend labels

谁都会走 提交于 2019-12-30 19:24:43
问题 How can I avoid duplicate legend labels in subplots? One way I would go about it in matplotlib would be to pass custom legend labels to an legend object. I couldn't find any documentation for an equivalent option in plotly. Any ideas? traces = [] colors = {'Iris-setosa': 'rgb(31, 119, 180)', 'Iris-versicolor': 'rgb(255, 127, 14)', 'Iris-virginica': 'rgb(44, 160, 44)'} for col in range(4): for key in colors: traces.append(Histogram(x=X[y==key, col], opacity=0.75, xaxis='x%s' %(col+1), marker

Using formattable and plotly simultaneously

假装没事ソ 提交于 2019-12-30 11:14:10
问题 If formattable and plotly are used simultaneously the error "Error in last_plot() : The last plot doesn't exist" is given if the following code is run which is a problem already mentioned by Nico Katze in the comment section of http://www.magesblog.com/2016/01/formatting-table-output-in-r.html. library(formattable) library(plotly) DF <- data.frame(Ticker=c("", "", "", "IBM", "AAPL", "MSFT"), Name=c("Dow Jones", "S&P 500", "Technology", "IBM", "Apple", "Microsoft"), Value=accounting(c(15988.08

Plotly: How to retrieve values for major ticks and gridlines?

空扰寡人 提交于 2019-12-30 10:45:12
问题 I'd like to retrieve the x-values highlighted in this plot: The plot is generated in a Jupyter Notebook using this snippet: import plotly import cufflinks as cf from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot import pandas as pd import numpy as np # setup init_notebook_mode(connected=True) np.random.seed(123) cf.set_config_file(theme='pearl') # Random data using cufflinks df = cf.datagen.lines() # plot fig = df.iplot(asFigure=True, kind='scatter',xTitle='Dates'

How to simultaneously apply color/shape/size in a scatter plot using plotly?

僤鯓⒐⒋嵵緔 提交于 2019-12-30 08:02:43
问题 I am trying to create (in plotly ) a scatterplot which distinguishes the points of the same series by two (or three) aesthetics -- color, shape, size. Ultimately the objective is to be able to toggle groups of points on/off via the legend, using any of the three aesthetics. This works well for one aesthetic. [Added 2016-06-20] To expand on the desired interactive behavior: The idea is, once the figure is shown, to be able to toggle groups of points by clicking on any of the legends. For

How to simultaneously apply color/shape/size in a scatter plot using plotly?

可紊 提交于 2019-12-30 08:02:34
问题 I am trying to create (in plotly ) a scatterplot which distinguishes the points of the same series by two (or three) aesthetics -- color, shape, size. Ultimately the objective is to be able to toggle groups of points on/off via the legend, using any of the three aesthetics. This works well for one aesthetic. [Added 2016-06-20] To expand on the desired interactive behavior: The idea is, once the figure is shown, to be able to toggle groups of points by clicking on any of the legends. For