-1

I'm trying to plot a team's score in a competition over time, compared to the max and the min of teams' scores at that time. I have a working example with min & max as lines.

However, I would prefer showing the min and the max via a shaded area, a bit like this picture but without the average of the min and max being plotted (the blue line).

Can someone more competent in Seaborn or matplotlib help me out?

I've unsuccessfully tried:

  • stopping the min & max's average line from being calculated at all
  • hiding the min & max's average line (e.g. reducing its size to 0)
  • tweaking Seaborn's confidence interval "ci" as per this answer

I have a preference for using Seaborn because of its nice "look & feel" but at this point, I'll take whatever works.


Dataset shown on the graph

      timestamp group    score
4  1.563890e+09    13    0.000
0  1.563890e+09   min    0.000
0  1.563890e+09   max  100.000
4  1.563890e+09    13    0.000
0  1.563890e+09   min    0.000
0  1.563890e+09   max   99.675
4  1.563890e+09    13    0.000
0  1.563890e+09   min    0.000
0  1.563890e+09   max   99.675
0  1.563890e+09    13   39.101
0  1.563890e+09   min    0.000
0  1.563890e+09   max   74.573
0  1.563890e+09    13   39.101
0  1.563890e+09   min   37.853
0  1.563890e+09   max   74.573`

code of first screenshot (scoreboard is a larger pandas dataframe)

s = scoreboard[(scoreboard.group == 13) | (scoreboard.group == "max") | (scoreboard.group == "min")]
sns.lineplot(x="timestamp", y="score", hue="group", data=s, marker="o")

code of second screenshot (scoreboard is a larger pandas dataframe)

s = scoreboard[(scoreboard.group == 13)]
s0 = scoreboard[(scoreboard.group == "max") | (scoreboard.group == "min")]

sns.lineplot(x="timestamp", y="score", data=s0, marker="o")
sns.lineplot(x="timestamp", y="score", data=s, marker="o")

Marc
  • 13
  • 2
  • You can achieve it via [fill_between()](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.fill_between.html). It's hard to try with the example you give. Could you post some of your raw data? – steven Jul 24 '19 at 15:53

1 Answers1

0

Without the data, it's not obvious how to give you specific lines of code. But considering how you are thinking of it, which is overlaying a glyph over another, I recommend you look at Bokeh. It's another Python viz library, that provides exactly that and remains compatible with pandas dataset.

Erick
  • 16
  • Thanks Erick, that was exactly what i was looking at when you posted your answer. I confirm Bokeh looks promising! – Marc Jul 24 '19 at 17:45