|
| 1 | +--- |
| 2 | +layout: manual |
| 3 | +title: Making Plots |
| 4 | +subtitle: "Tips and tricks for making better plots." |
| 5 | +permalink: /manual/guides/plots/ |
| 6 | +--- |
| 7 | + |
| 8 | + |
| 9 | +This guide provides best practices for ensuring that plots created by ARFC are |
| 10 | +accessible and visually clear. By following these simple recommendations, you |
| 11 | +will make your work more inclusive, readable, and aligned with accessibility |
| 12 | +standards. |
| 13 | + |
| 14 | + |
| 15 | +## 1. Using Color |
| 16 | + |
| 17 | +Color combinations like red, green, brown, orange, and yellow can be difficult |
| 18 | +to distinguish for people. Instead, use distinguishable patterns and contrast; |
| 19 | +different line styles, shapes, and markers can help differentiate elements |
| 20 | +without relying on color. |
| 21 | + |
| 22 | +This does not mean you cannot employ a color pallette, **Sequential palettes** |
| 23 | +should be used for data with a natural order (e.g., temperature), while |
| 24 | +**diverging palettes** are better suited for data with two distinct extremes. |
| 25 | +Popular accessible color palettes include **Cividis**, **Viridis**, and |
| 26 | +**Inferno**, which are perceptually uniform. Avoid the Jet (rainbow) |
| 27 | +colormap, as it is not perceptually uniform. It often causes difficulty in |
| 28 | +interpreting data, as colors that are close to each other can look almost |
| 29 | +identical, while distant colors may appear too different. |
| 30 | + |
| 31 | + |
| 32 | +## 2. Choosing Font |
| 33 | + |
| 34 | +Choose sans-serif fonts (like **Arial**, **Helvetica**, **Verdana**), as they |
| 35 | +are generally easier to read compared to serif fonts (e.g., Times New Roman).In |
| 36 | +addition to a good font, your text should also have enough contrast against the |
| 37 | +background for readability. |
| 38 | +- For headings, the contrast ratio should be at least 3:1. |
| 39 | +- For body text, the contrast ratio should be at least 4.5:1. |
| 40 | + |
| 41 | +Avoid fonts with narrow letter spacing or uneven height (between lowercase and |
| 42 | +uppercase) as they exacerbate all of the above problems. Keep text, whitespace, |
| 43 | +and figures evenly spaced, allowing for easy zooming and reading. |
| 44 | + |
| 45 | + |
| 46 | +## 3. Use of Markers and Line Styles |
| 47 | + |
| 48 | +To ensure that your plots will stand the test of time by using non-color-based |
| 49 | +visual cues like: |
| 50 | +- Markers (e.g., circles, squares, triangles) to differentiate data points. |
| 51 | +- Line styles (e.g., dashed, dotted, solid) to distinguish data in a line plot. |
| 52 | + |
| 53 | +This will help ensure that even if a user has difficulty distinguishing certain |
| 54 | +colors, they can still interpret the plot accurately. |
| 55 | + |
| 56 | + |
| 57 | +## 4. Plot Size and Resolution |
| 58 | + |
| 59 | +Make sure your plots are high resolution so that details are not lost when |
| 60 | +zooming in. In addition to a high resolution your plots should be high-quality |
| 61 | +formats (e.g., **SVG**, **PDF**). |
| 62 | + |
| 63 | + |
| 64 | +## 5. Matplotlib Style File for ARFC |
| 65 | + |
| 66 | +To standardize the style of your plots, you can use a **Matplotlib style file** |
| 67 | +that reflects ARFC's standards. This will help ensure that all plots follow the |
| 68 | +same formatting conventions, making them visually consistent and aligned with |
| 69 | +our standards. |
| 70 | + |
| 71 | +You can use this style file to configure: |
| 72 | +- font, |
| 73 | +- color palettes, |
| 74 | +- plot dimensions, |
| 75 | +- and figure size. |
| 76 | + |
| 77 | +A Matplotlib style file is available here: |
| 78 | +https://gist.github.com/nsryan2/456490df118ab3318ec07c7610432e69. |
| 79 | +It uses Paul Tol's muted qualitative color scheme as the default. |
| 80 | + |
| 81 | +### Example: |
| 82 | + |
| 83 | +Here's a minimal example of how you can apply the style file to Python: |
| 84 | + |
| 85 | +```python |
| 86 | +import matplotlib.pyplot as plt |
| 87 | + |
| 88 | +# Load the ARFC style file |
| 89 | +plt.style.use('path/to/plotting.mplstyle') |
| 90 | + |
| 91 | +# Create a sample plot |
| 92 | +x = [1, 2, 3, 4, 5] |
| 93 | +y1 = [1, 4, 9, 16, 25] |
| 94 | +y2 = [2, 3, 9, 16, 26] |
| 95 | + |
| 96 | +plt.plot(x, y1, label='Sample 1', marker='o', linestyle='-') |
| 97 | +plt.plot(x, y2, label='Sample 2', marker='+', linestyle='--') |
| 98 | + |
| 99 | +plt.xlabel('X Axis') |
| 100 | +plt.ylabel('Y Axis') |
| 101 | +plt.legend() |
| 102 | +plt.show() |
| 103 | +``` |
0 commit comments