plotly-python

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/

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

facet labels in plotly

徘徊边缘 提交于 2021-02-08 10:40:15
问题 I'd like to change the facet labels in a plotly(_express) plot. Here's the plot: import plotly.express as px tips = px.data.tips() fig = px.scatter(tips, x="total_bill", y="tip", color="smoker", facet_col="sex") fig.show() What I'd like is to remove the sex= from the labels. 回答1: UPDATE: as of plotly version 4.2 in October 2019, the following usage of for_each_annotation is recommended by the docs at https://plotly.com/python/facet-plots/#customize-subplot-figure-titles import plotly.express

Plotly: How to assign specific colors for categories? [duplicate]

回眸只為那壹抹淺笑 提交于 2021-02-08 05:55:22
问题 This question already has an answer here : Plotly: How to define colors in a figure using plotly.graph_objects and plotly.express? (1 answer) Closed 5 days ago . I have a pandas dataframe of electricity generation mix. So it consists of electricity generation by different fuels. I want to assign a specific color to a specific fuel. In Matplotlib, it is convenient to assign a specific color to a specific category by passing a list of colors, e.g. df.plot(kind="bar",color=["red","green","yellow

Visualizing time series data of graph nodes in plotly

北城余情 提交于 2021-02-08 04:38:23
问题 I've a graph created in Networkx and plotted using plotly Code: import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt import plotly.graph_objects as go from pprint import pprint from collections import OrderedDict def get_edge_trace(G): edge_x = [] edge_y = [] for edge in G.edges(): x0, y0 = G.nodes[edge[0]]['pos'] x1, y1 = G.nodes[edge[1]]['pos'] edge_x.append(x0) edge_x.append(x1) edge_x.append(None) edge_y.append(y0) edge_y.append(y1) edge_y.append

Change subplots title position/orientation in Plotly Python

安稳与你 提交于 2021-02-04 07:24:49
问题 I need to change subplot title in python plotly, namely, rotate it by 90 degrees. I tried hard but without any success. Here is my code import plotly.offline as pyo import plotly.graph_objs as go from plotly import tools trace1 = go.Bar( x=[1, 2, 3], y=[10, 11, 12] ) trace2 = go.Bar( x=[1, 2, 3], y=[100, 110, 120], ) trace3 = go.Bar( x=[1, 2, 3], y=[1000, 1100, 1200], ) fig = tools.make_subplots(rows=1, cols=3, shared_xaxes=True, shared_yaxes=True, vertical_spacing=0.001, subplot_titles = (

Change subplots title position/orientation in Plotly Python

烈酒焚心 提交于 2021-02-04 07:24:24
问题 I need to change subplot title in python plotly, namely, rotate it by 90 degrees. I tried hard but without any success. Here is my code import plotly.offline as pyo import plotly.graph_objs as go from plotly import tools trace1 = go.Bar( x=[1, 2, 3], y=[10, 11, 12] ) trace2 = go.Bar( x=[1, 2, 3], y=[100, 110, 120], ) trace3 = go.Bar( x=[1, 2, 3], y=[1000, 1100, 1200], ) fig = tools.make_subplots(rows=1, cols=3, shared_xaxes=True, shared_yaxes=True, vertical_spacing=0.001, subplot_titles = (

How to show all legend in conditional plot and show several legends in plotly

只愿长相守 提交于 2021-01-29 08:29:13
问题 I am trying to make a plot similar to the next one: While I have until now is: Which is generated with the following code: import plotly.io as pio pio.renderers.default='browser' import plotly.graph_objects as go import pandas as pd import numpy as np input_df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv') threshold =2.8 name_yaxis="Gap" input_df["AAPL.High"] = (input_df["AAPL.High"]-min(input_df["AAPL.High"]))*(threshold)/(max(input_df[