plotly

How to make Plotly.js listen the click events of the tick labels?

北城余情 提交于 2020-07-05 12:33:15
问题 So, in this dynamic chart, I want to change the Y-axis' min and max values when any of the Y-axis' Tick Label is clicked. 回答1: You could add a d3 event listener to all y-ticks and make sure that the SVG group gets all the events. Wrapping the whole snippet in Plotly's afterplot event makes sure that the event listener does not get lost after updating the graph. var trace1 = { x: [1, 2, 3, 4], y: [10, 15, 13, 17], type: 'scatter' }; var trace2 = { x: [1, 2, 3, 4], y: [16, 5, 11, 9], type:

Plotly: How to plot a cumulative “steps” histogram?

▼魔方 西西 提交于 2020-07-05 12:32:41
问题 I am trying to plot a cumulative histogram using Plotly in python, but make it look like "steps", i.e. bars with no color and only the top line is displayed. Something like this: Basically, I'm trying to reproduce the behavior of the following matplotlib code: import matplotlib.pyplot as plt plt.hist(x, cumulative=True, histtype='step') So far, the best I've been able to do is: import plotly.graph_objs as go from plotly.offline import iplot h = go.Histogram(x=x, cumulative=dict(enabled=True),

How to make Plotly.js listen the click events of the tick labels?

半世苍凉 提交于 2020-07-05 12:26:21
问题 So, in this dynamic chart, I want to change the Y-axis' min and max values when any of the Y-axis' Tick Label is clicked. 回答1: You could add a d3 event listener to all y-ticks and make sure that the SVG group gets all the events. Wrapping the whole snippet in Plotly's afterplot event makes sure that the event listener does not get lost after updating the graph. var trace1 = { x: [1, 2, 3, 4], y: [10, 15, 13, 17], type: 'scatter' }; var trace2 = { x: [1, 2, 3, 4], y: [16, 5, 11, 9], type:

Display interactive plotly chart (.html file) on GitHub Pages

怎甘沉沦 提交于 2020-07-04 09:04:02
问题 I've created the following plotly plot like this: import plotly labels = ['Oxygen', 'Hydrogen', 'Carbon_Dioxide', 'Nitrogen'] values = [4500, 2500, 1053, 500] trace = plotly.graph_objs.Pie(labels=labels, values=values) plotly.offline.plot([trace], filename='basic-pie-chart') Then I created the html as such: print(plotly.offline.plot([trace], include_plotlyjs=False, output_type='div')) Running the code above generates an .html file that I can view in my browser. Is there a way to display the

Display interactive plotly chart (.html file) on GitHub Pages

試著忘記壹切 提交于 2020-07-04 09:03:29
问题 I've created the following plotly plot like this: import plotly labels = ['Oxygen', 'Hydrogen', 'Carbon_Dioxide', 'Nitrogen'] values = [4500, 2500, 1053, 500] trace = plotly.graph_objs.Pie(labels=labels, values=values) plotly.offline.plot([trace], filename='basic-pie-chart') Then I created the html as such: print(plotly.offline.plot([trace], include_plotlyjs=False, output_type='div')) Running the code above generates an .html file that I can view in my browser. Is there a way to display the

Using Plotly in Python Spyder IDE

有些话、适合烂在心里 提交于 2020-07-03 07:56:54
问题 Is it possible to use plotly in the Spyder IDE to produce figures that show only in Spyder instead of the browser? I'm not bothered about the interactivity of the plot, I just want to see the figures in the IDE. If I run the following code it just opens in the browser. If I change the last line to pyo.iplot instead of plot, it just does nothing. I'm a bit lost! import plotly.offline as pyo from plotly.graph_objs import Figure, Data pyo.offline.init_notebook_mode() x = list(range(10)) y = [22

Plotly: How to make an annotated confusion matrix using a heatmap?

早过忘川 提交于 2020-07-03 07:27:06
问题 I like to use Plotly to visualize everything, I'm trying to visualize a confusion matrix by Plotly, this is my code: def plot_confusion_matrix(y_true, y_pred, class_names): confusion_matrix = metrics.confusion_matrix(y_true, y_pred) confusion_matrix = confusion_matrix.astype(int) layout = { "title": "Confusion Matrix", "xaxis": {"title": "Predicted value"}, "yaxis": {"title": "Real value"} } fig = go.Figure(data=go.Heatmap(z=confusion_matrix, x=class_names, y=class_names, hoverongaps=False),

Plotly: How to make an annotated confusion matrix using a heatmap?

跟風遠走 提交于 2020-07-03 07:26:42
问题 I like to use Plotly to visualize everything, I'm trying to visualize a confusion matrix by Plotly, this is my code: def plot_confusion_matrix(y_true, y_pred, class_names): confusion_matrix = metrics.confusion_matrix(y_true, y_pred) confusion_matrix = confusion_matrix.astype(int) layout = { "title": "Confusion Matrix", "xaxis": {"title": "Predicted value"}, "yaxis": {"title": "Real value"} } fig = go.Figure(data=go.Heatmap(z=confusion_matrix, x=class_names, y=class_names, hoverongaps=False),

Subplots deploying in R Plotly

与世无争的帅哥 提交于 2020-06-29 19:24:30
问题 I would be grateful if anyone could tell me how to specify domain layout to get same size pie charts in few columns. I have already found this example, however, I do not know what each argument of domain option mean and how do resize them and deploy properly, not many info in documentation. plot_ly() %>% add_pie(data = count(diamonds, cut), labels = ~cut, values = ~n, name = "Cut",domain = list(x = c(0.4, 0.9), y = c(0.4, 1)),hole = 0.6) %>% add_pie(data = count(diamonds, color), labels =

Subplots deploying in R Plotly

久未见 提交于 2020-06-29 19:23:29
问题 I would be grateful if anyone could tell me how to specify domain layout to get same size pie charts in few columns. I have already found this example, however, I do not know what each argument of domain option mean and how do resize them and deploy properly, not many info in documentation. plot_ly() %>% add_pie(data = count(diamonds, cut), labels = ~cut, values = ~n, name = "Cut",domain = list(x = c(0.4, 0.9), y = c(0.4, 1)),hole = 0.6) %>% add_pie(data = count(diamonds, color), labels =