Let's say I have the following datafarme:
+-------------------+--------+--------+--------+
|timestamp |average |min |max |
+-------------------+--------+--------+--------+
|2021-08-11 04:05:06|2.0 |1.8 |2.2 |
|2021-08-11 04:15:06|2.3 |2.0 |2.7 |
|2021-08-11 09:15:26|2.5 |2.3 |2.8 |
|2021-08-11 11:04:06|2.3 |2.1 |2.6 |
|2021-08-11 14:55:16|2.6 |2.2 |2.9 |
|2021-08-13 04:12:11|2.1 |1.7 |2.3 |
+-------------------+--------+--------+--------+
I want to plot average
values in the form of a scatter plot and also plot min
and max
columns using a dashed line plot and then fill between areas average
& max
as well as average
& min
separately as it is shown in fig 1 in the table.
I found some close examples:
- How to create a min-max plot by month with fill_between
- How to plot min max line plot in python pandas
I aim to develop this to reach something like plt.errorbar()
(which deals with mean and std) example 1, example 2 but I just want to illustrate min
and max
values instead of ~~mean & std~~ over time as follows:
Fig. 1: without errorbar style. | Fig. 2: with errorbar style. |
sadly I could not find the output example for fig 2 since normally they used to translate mean and std with data points but for fig 1 this post but it for r language is what part of what I want but the area color should be filled with different color (light red and blue) separately.
Any help and guidance will be appreciated.
Since you have not specified the library of visualizations to use, I have
plotly.graph_objects
created the graph for your purposes. The graph will consist of a scatter plot line type with error bars, and a scatter plot line type with maximum, average, and minimum lines. The reason why I am drawing the line of averages is to paint the maximum and minimum. The only difference from the output in your question is the color of the lines in the error bars. plotly automatically processes time series data on the x-axis.