-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: colors in line charts are often very similar #3898
Comments
This isn't a high priority comment. But I hope it is useful to you. If not and these sorts of comment are wasting your time or just annoying, ask me to stop, I won't be offended. I've tried to format it so it's not overwhelming but so there's some deeper dives possible for interested folk. I'm assuming low knowledge and sticking at that pace, it's not directed at any one person's decision or work. A search of the grapher repo returns "192 matches across 51 files" for HSL in a layman styletl;dr: HSL presents colour as a set of values designed for people, unlike HEX, designed for computers. It's syntactic sugar really, but improves the DX drastically. Hue is the colour of visible light, saturation is how much of it there is (fade to grey) and lightness (or luminescence) is how much light there is (fade to black). Also it shows how the values can be manipulated with simple to understand arithmetic. Images taken from GIMP are used to demonstrate this, and there are some links to CSS tricks and MDN which get into the technical detail. HSL: a broad overview===================================== HSL Definition:Hue: is a wheel of colour that rolls round from red, through orange, to yellow, then green, blue, purple and finally back to red. Typically it runs through 360 degrees, like a compass. Note that there is no pink. Pink is really light red, you'll notice on some artists paints that the pinks are in the red range. Saturation: is the amount of hue in the result. Usually a %. Set to Lightness / Luminescence: Two words that mean roughly the same and start with L. Again, usually a % with HSL is usually much simpler for people to understand, whereas mixtures of RGB are more computer focused. Monitors use a mixture of R, G and B to produce the range of colours, which we know from hex codes in CSS, whereas HSL puts the colour into one place which we understand because it is closer to what we see then uses saturation and lightness, again, a closer match to our experience with eyes, assuming sightedness. It's also much easier to do arithmetic with. [1] now isn't the time to get into why paint uses yellow and not green as a primary colour. In CSSI'll let the excellent CSS Tricks site explain how it works in CSS style sheets. And the MDN docs, just because they're great. CSS also has an alpha property is HSLA, that defines opaqueness. An exampleIn these examples look at the bottom left for "Current" colour. A hue changeYou can see how the S and L portions are the same but the Hue selection is moved. Grey-scaleHere we see the exact same Hue and Lightness as the previous example, but the removal of all saturation results in grey. This grey would be the same regardless of hue. BlackHere's the same hue again, this time with no lightness, resulting in black. The same applies where this occurs with any hue. Final noteHSL is really syntactic sugar for referring to light from a luminescent source, in a computer it's converted into RGB for display; this is different from light reflected off an object (like something painted) which is why RGB are primary on screens, and Red, Blue and Yellow are primary in paints. I'll leave colour there for now, hope this explanation helps. The topic can take a life's work and I'm no expert by any means. ===================================== An example of how this manifests on different chartstl;dr: I take a few images from my own site to show how this looks, including the line graph which I've not actually got live yet in my work. I've linked directly to the histogram page because it's probably the best one for demonstrating the ideas and code plus it's interactive, and using "deviation" will show the alpha level opacity which HSL: some examples in charts===================================== Line graphSeen as that's the subject, that's what I'll show first HistogramThough I'm also going to show this - IMO, it works very well with Histograms (therefore also Marimekko, Stacked ... The first example doesn't need to toggle, spreading the colour works: 360 / 3 = quiet enough difference.This set of two show with a force toggle and without - the code section will cover the toggle===================================== CodeA couple of functions from my work are defined, cleaned of some cruft and annotated. I use this in quite a few places. Code
What's notable about the code, apart from how simple it is, is that the colour choice is basic arithmetic and very clear to understand for the reader. This relates back to the earlier section about manipulation and being more human friendly than HEX (or RGB for that matter). It matches how artists and designers think so the developer is using a language that's understood by a broader set of colleagues who don't need to be technical. Then if you're confronted by more challenging colour logic, like what might lie under support of the various colour interpretations people have, my hypothesis would be that the task would be easier using this tool than direct HEX values. Final note: there are numerous accessibility problems with "just colour" solutions, but that's a separate topic. |
I'd originally sent this message on Slack on 13 Sep. Just copying here so it's kept together with this issue. I think there are two related things here:
I wanted to add that I experienced a similar thing today, with grapher and similar (to my eye at least!) line colors being selected. I’m curious if others see these colors as more distinct than I do? this could all just be me!
|
Thanks for sharing the Slack information, Where I am I have a good viewing setup (MacBook, shaded area), plus I have eyes that are very good at seeing colour differences, these make me a poor test candidate. All I'd add now is that the line thickness contributes - I think this is clear in my earlier comment where I show some examples of bar and line charts; and I'm very sure at 0 zoom Charlie's examples would be harder for me. |
@CGiattino I came back to this thinking some simulations might be worth looking at. I ran them through the simulators found here at PillStone. The simulator is on this page. I ran all eight, which you'll find in the enclosed sections below, along with a histogram example of hue toggling and wheeling (from my site). Without knowing a great deal about the medical side of this topic I took it on trust, and high google position, but a good case in support of their breakdown is that it matches StoryBook's. Parlance is copied, but the topic's got some depth. The whole green and red "classic" puts forward complexities beyond this comment. EDIT: Added a credible source for the terms used from the American Academy of Ophthalmology. |
I realized what the current logic of picking colors in line charts is. Basically, colors are picked sequentially from our palette: Say you've selected In #4003, we are trying to optimize the colors for a selection of I've confirmed my hypothesis by playing with this chart and forcing the selection of colors 2, 6, 9 ,11, 13, 16, 19, 21, 24. I see the motivation for this behavior: if we were to bring back unselected entities, they should retain the color they were first shown with. But I wonder if the cost of this (i.e., producing charts with sub-optimal color choices) is higher than the benefit. My opinion: When an entity is unselected, it is totally fine for it to lose its "color slot." If it is unselected and selected right away, it will retain the "color slot" (I think that makes sense). But if it is unselected and some other countries are selected before it is selected again, it is fine for it to just have whatever color the palette specifies. |
To add to my previous comment, I think the current color-picking logic makes even less sense in the admin page (i.e. when we are creating a chart). In a new chart, when choosing the entities to display, the colors picked should not be affected by whether the power user did unselections. My sense, however, is that the colors that the power user sees when creating a new chart vs. the colors shown when the chart is actually public don't necessarily match. That is, the colors in the latter will be based on the order of our color palette (i.e., regardless of any unselections during chart-editing). |
Description
Line colors in line charts colors are sometimes very similar depending on the entities selected.
Expected behavior
All lines in the chart should have colors that are easy to distinguish. This can be achieved by choosing from our palette smartly.
Steps to reproduce
Steps to reproduce the behavior:
Environment
For desktop, provide:
Additional context and screenshots
After playing with selecting and unselecting entities in this chart, I realized that the lines were not very distinct. I am a bit confused by the rules for the Grapher when choosing colors.
color-charts.mov
If one refresh, the chart is loaded with distinguishable colors (second video).
demo-color-2.mov
I think this often leads to DI charts with similar line colors.
The text was updated successfully, but these errors were encountered: