scales: colors and numbers
Replicate (1, 2, 3)Treatment (“Control”, “Drug”)Speed (decimal values)| Replicate | Treatment | Speed |
|---|---|---|
| 1 | Control | 43.69202 |
| 1 | Control | 41.85664 |
| 1 | Control | 49.11707 |
| 1 | Control | 49.79331 |
| … | … | … |
Do any of these panels stand out as familiar, helpful, confusing, surprising?
What data might go into the forecast graphic and how else could we represent that more effectively?
Color contrast measures the difference in luminance1 between two colors. A few good options are below.
For text:
standard defines an acceptable contrast ratio as at least 3:1 for large or bold text and icons and 4.5:1 for general reading text.
For graphics:
shapes, icons, and large text relative to their background color meets a minimum ratio of 3:1.
Regardless of contrast, color alone should rarely be used. Encode redundantly with symbols, patterns, or labeling.
Color is a complicated subject.
It helps to have a variety of tools, though ever-changing, to explore.
We can do a bit of experimentation with the palette() command to set in-session color defaults.
Pause to experiment.
The webpage has a great interactive tool showcasing one key achievement of this color model - lightness.
Some companies have style or branding guides that could influence what colors are available for use in data visualizations.
To compensate you could
Suppose we are interested in “percent change” as a metric.
| Percent change | Multiplier |
|---|---|
| 700% | 8 |
| 100% | 2 |
| 0% | 1 |
| -50% | \(\frac{1}{2}\) |
| -87.5% | \(\frac{1}{8}\) |
Graph all three columns of the data in exponential.csv, first on linear scale and next on a log scale.
Observe how the use of vertical space draws attention to the “action” in the data. In other words, “what do you notice?”
The default R axes are not necessarily pleasing.
As it is, few things will change that.
The default R axes are not necessarily pleasing.
What to plot, what to label?
Regardless of choice, how do we make it user-friendly and “nice” aesthetically?
Suppress axes with axes = F, but invite them back with the axis() command.
You’ll have to ask and answer
Fortunately we do not have to worry about the horizontal axis (here representing “time”) because that pretty much only makes sense on a linear scale.
Suppose we wanted to show tick mark labels as powers of ten.
After setting axes = F, we could try a variety of things using axis(). We could
at locationsat locations and labelsat locations and labels (one at a time)Or we could (and will) use more advanced tools or specialized packages.
To illustrate value use a linear scale, to inspect rate of change use a log scale.
Consider the log-transformation of \(y = ae^{bt}\) which becomes \(\ln(y) = \ln(a) + bt\). (Verify this.)
For convenience we use the natural logarithm, but the rules work the same for any other choice of base.
This means the underlying exponential parameter \(b\) is emphasized as the slope when graphed on the log scale.