plotly

Plotly / How to change the default color pallete in Plotly?

孤人 提交于 2021-02-16 14:46:15
问题 I was able to force the default theme using import plotly.io as pio pio.templates.default = 'plotly_white' But I am struggling to set a default color palette. Any ideas how to change this? Thanks 回答1: You can add new items to pio.templates . import plotly.io as pio import plotly.graph_objects as go pio.templates["myname"] = go.layout.Template( layout=go.Layout( colorway=['#ff0000', '#00ff00', '#0000ff'] ) ) pio.templates.default = 'myname' See more here: https://plotly.com/python/templates/

add_trace in Plotly in a loop [duplicate]

强颜欢笑 提交于 2021-02-16 13:25:11
问题 This question already has an answer here : Building plotly graph in for loop not displaying all series (1 answer) Closed 3 years ago . I want to plot multiple traces in a loop without overwriting all previous traces. In this post from 2015, a solution to adding traces within a loop is presented, by setting evaluate = TRUE in the plot_ly or add_trace functions. However, as of 2017 in the newer version of plot_ly, evaluate isn't an attribute. 'scatter3d' objects don't have these attributes:

add_trace in Plotly in a loop [duplicate]

谁说我不能喝 提交于 2021-02-16 13:24:27
问题 This question already has an answer here : Building plotly graph in for loop not displaying all series (1 answer) Closed 3 years ago . I want to plot multiple traces in a loop without overwriting all previous traces. In this post from 2015, a solution to adding traces within a loop is presented, by setting evaluate = TRUE in the plot_ly or add_trace functions. However, as of 2017 in the newer version of plot_ly, evaluate isn't an attribute. 'scatter3d' objects don't have these attributes:

Plotly stacked bar chart pandas dataframe

可紊 提交于 2021-02-16 09:26:32
问题 I have a dataframe with a varying number of columns. With positive and negative values. Is it possible to make a stacked bar chart with all of these columns in the dataframe? A B C 0 34 34 -12 1 34 223 -12 2 34 56 -12 3 34 86 -12 4 56 86 -12 5 56 43 -12 6 78 34 -12 回答1: (Updated answer for newer versions of plotly) Using px.bar will give you a stacked bar chart directly. If your bar chart for some reason is not stacked, try: fig.update_layout(barmode='stack') Complete code: import pandas as

Plotly: How to set custom xticks

末鹿安然 提交于 2021-02-16 08:38:09
问题 From plotly doc: layout > xaxis > tickvals: Sets the values at which ticks on this axis appear. Only has an effect if tickmode is set to "array". Used with ticktext . layout > xaxis > ticktext: Sets the text displayed at the ticks position via tickvals . Only has an effect if tickmode is set to "array". Used with tickvals . Example: import pandas as pd import numpy as np np.random.seed(42) feature = pd.DataFrame({'ds': pd.date_range('20200101', periods=100*24, freq='H'), 'y': np.random

Plotly: How to set custom xticks

时光总嘲笑我的痴心妄想 提交于 2021-02-16 08:38:04
问题 From plotly doc: layout > xaxis > tickvals: Sets the values at which ticks on this axis appear. Only has an effect if tickmode is set to "array". Used with ticktext . layout > xaxis > ticktext: Sets the text displayed at the ticks position via tickvals . Only has an effect if tickmode is set to "array". Used with tickvals . Example: import pandas as pd import numpy as np np.random.seed(42) feature = pd.DataFrame({'ds': pd.date_range('20200101', periods=100*24, freq='H'), 'y': np.random

Plotly: How to set custom xticks

风流意气都作罢 提交于 2021-02-16 08:37:38
问题 From plotly doc: layout > xaxis > tickvals: Sets the values at which ticks on this axis appear. Only has an effect if tickmode is set to "array". Used with ticktext . layout > xaxis > ticktext: Sets the text displayed at the ticks position via tickvals . Only has an effect if tickmode is set to "array". Used with tickvals . Example: import pandas as pd import numpy as np np.random.seed(42) feature = pd.DataFrame({'ds': pd.date_range('20200101', periods=100*24, freq='H'), 'y': np.random

R: Switching Between Graphs

不羁的心 提交于 2021-02-15 07:42:54
问题 I am using the R programming language. I am trying to follow the tutorial here on "switching between graphs" : https://plotly.com/r/dropdowns/ (first example). First, I generated some data in R: library(plotly) library(MASS) x <- sample( LETTERS[1:4], 1000, replace=TRUE, prob=c(0.25, 0.25, 0.25, 0.25) ) y <- rnorm(1000,10,10) z <- rnorm(1000,5,5) df <- data.frame(x,y, z) df$x = as.factor(df$x) colnames(df) <- c("x", "y", "z") I tried to modify the code from this tutorial to make the final

Plotly legend next to each subplot, Python

点点圈 提交于 2021-02-13 07:52:31
问题 After noticing that there was no answer to this question at the moment, I would like to know if anyone has an idea how to: Have a legends for each subplot. Group legends by name. (Ex: for different subplots, all have the same two curves but with different values). Here's my Plotly script: from plotly import tools import plotly.plotly as py import plotly.graph_objs as go import plotly nom_plot=[] trace1 = go.Scatter(x=[1, 2, 3], y=[4, 5, 6],name='1',showlegend=True) nom_plot.append('GRAPH 1')

Plotly legend next to each subplot, Python

杀马特。学长 韩版系。学妹 提交于 2021-02-13 07:51:48
问题 After noticing that there was no answer to this question at the moment, I would like to know if anyone has an idea how to: Have a legends for each subplot. Group legends by name. (Ex: for different subplots, all have the same two curves but with different values). Here's my Plotly script: from plotly import tools import plotly.plotly as py import plotly.graph_objs as go import plotly nom_plot=[] trace1 = go.Scatter(x=[1, 2, 3], y=[4, 5, 6],name='1',showlegend=True) nom_plot.append('GRAPH 1')