owid-grapher icon indicating copy to clipboard operation
owid-grapher copied to clipboard

StackedArea: Negative values are plotted as area

Open sophiamersmann opened this issue 9 months ago • 2 comments

Description

Stacked area charts plot negative values as area, which is misleading. (The tooltip shows the negative values though)

Expected behaviour

Don't plot areas for negative values.

Steps to reproduce

  1. Go to https://ourworldindata.org/grapher/co2-emissions-fossil-land?country=~DEU
  2. Hover over the year 2000
  3. Note that "Land-use change" has a negative values but is plotted as if it's a positive value
  4. See error

Screenshots

Screenshot 2024-05-01 at 10 37 53

sophiamersmann avatar May 01 '24 09:05 sophiamersmann

What's worth mentioning is that, at least, the negative numbers are creating a "negative area", i.e. one that is hanging below the other one. This means that at least the total is still kind-of correct (if you were to look at the lower end of the green area).

But I agree that correct handling of negative values in StackedArea is rather tricky. One important such chart that has negative values is https://ourworldindata.org/grapher/ozone-depleting-substance-consumption...

marcelgerber avatar May 01 '24 12:05 marcelgerber

This is tricky - we discussed it a bit in data viz triage. What we think we want to do:

  • fix the extent of the Y axis so that it shows negative values correctly like in https://ourworldindata.org/grapher/ozone-depleting-substance-consumption at the end
  • attempt to sort time series with negative values down in the visual order of stacked indicators so that negative areas tend to extend down
  • attempt to use a striped pattern (like we use on maps for NA areas) for negative areas

Stacked bar charts (and probably stacked discrete bar charts) have a similar issue and are probably easier to fix, so more valuable.

Our appetite is probably a day or so

danyx23 avatar May 22 '24 14:05 danyx23