Replies: 5 comments
-
I managed to created this plot from the wealth dataset listed above using matplotlib: It required a lot of custom code however, so if seaborn could provide an interface for this that would be amazing! |
Beta Was this translation helpful? Give feedback.
-
Is this not something that could be accomplished with fmri = sns.load_dataset("fmri").query("region == 'parietal'")
for interval in [50, 90, 95, 99]:
sns.lineplot(
fmri, x="timepoint", y="signal",
estimator="median", errorbar=("pi", interval),
color="C0",
) There are a couple of downsides here; it requires some redundant computation of the median (maybe slow for large datasets) and But it feels easier and more flexible with the objects interface: p = so.Plot(fmri, "timepoint", "signal")
for tail in [25, 10, 5, 1]:
p = p.add(so.Band(), so.Perc([tail, 100 - tail]))
p.add(so.Line(), so.Agg("median")) |
Beta Was this translation helpful? Give feedback.
-
For my example dataset it works, and it's so extremely simple! I had no idea it could be so easy. for interval in [50, 90, 98]:
plot = sns.lineplot(wealth, estimator="median", errorbar=("pi", interval), color="C0") Seaborn truly is amazing! Could you leave this issue open? I would like to document this in an example. Then we can close this issue. |
Beta Was this translation helpful? Give feedback.
-
So I want to add this one as an example, but I think a legend would be useful which band represents which percentile. Is that possible, and if so, how could I add one using the objects interface?
|
Beta Was this translation helpful? Give feedback.
-
You're basically asking about #3046, but if you're going to get differently-colored bands with alpha compositing than a simple legend for each band isn't going to make much sense. Also I would prefer that the example gallery remain restricted to the function interface for now. |
Beta Was this translation helpful? Give feedback.
-
Timeseries distribution plot
Sometimes you have a large population dataset that you want to visualize over time. Being able to quickly view how population values change over time could be very useful in this case. Two example plots are shown below.
The goal is to have a plot which shows different bands for different distribution values. For example, the median is a solid line, the middle 50 percentiles (25th to 75th) is the darkest color band, the 90 percentile (5th to 95th) is an tint lighter bar and the 98 percentile (1 to 99) is displayed with the lightest tint.
Naming and values
The plot could be named
seaborn.timeseries_distribution()
, with as input a Pandas series or a dictionary.Using the values above, the default values could be:
Input data
The input should be data containing multiple values for each point in time. This could be in the form of a Pandas series:
In which the timestep is the index and the values the series values.
A dict, with the timestep as key and the values in a list, could also be possible:
A DataFrame might also be possible, where the index is still the timestep and the column you select contains the values.
Sample data
Here is some sample data in Series form, containing 200 values for each of the 100 timestamps: wealth.zip.
The Pickle file in the ZIP file can be read with:
And converted to the dict with :
Existing examples
As for how it could look like, here are two examples I found:
Source: https://minimizeregret.com/post/2020/06/07/rediscovering-bayesian-structural-time-series/
Scope
Such plots could be very useful for simulation models or timeseries gathered population data. I'm curious if it might be in the scope of Seaborn.
Beta Was this translation helpful? Give feedback.
All reactions