Skip to content
Advertisement

Plotly: How to make a figure with multiple lines and shaded area for standard deviations?

How can I use Plotly to produce a line plot with a shaded standard deviation? I am trying to achieve something similar to seaborn.tsplot. Any help is appreciated. enter image description here

Advertisement

Answer

The following approach is fully flexible with regards to the number of columns in a pandas dataframe and uses the default color cycle of plotly. If the number of lines exceed the number of colors, the colors will be re-used from the start. As of now px.colors.qualitative.Plotly can be replaced with any hex color sequence that you can find using px.colors.qualitative:

JavaScript

enter image description here

Complete code:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement