Written and maintained by CASRAI Editorial Board
Last updated
A great data visualization example, for a researcher, is a figure that delivers one message to a defined audience without misleading anyone. Most lists of examples rank famous graphics by how striking they look. This guide judges examples against a published standard instead, the PLOS Computational Biology paper “Ten Simple Rules for Better Figures” (Rougier, Droettboom and Bourne, 2014), and then shows how to build the chart types that the official matplotlib and ggplot2 galleries demonstrate.
What great data visualization examples are used for in research
Researchers look at examples for two reasons: to pick a chart type that fits their data, and to find a figure design they can adapt. The Rougier paper is direct about the second use. Its Rule 9, “Message Trumps Beauty”, says that when no standard way of describing your research exists, browsing the scientific literature is a good starting point, and that you may adapt a stunning figure to your own needs, though the authors stress “adapt”, not “copy”, and warn to be careful with image copyright.
The same rule draws a line that most “best visualizations” lists ignore: the authors note that many online graphics put aesthetics first and content second, and that most of them do not fit the scientific framework. In science, they write, the message and readability of the figure matter most, and beauty is only an option.
Which chart types the official galleries show
The matplotlib gallery is organised into sections that include Lines, bars and markers; Images, contours and fields; Statistics; Text, labels and annotations; Color; Style sheets; 3D plotting; Animation; Showcase; and Specialty plots. Example titles you can open and copy code from include Line plot, Stacked bar chart, Histograms, Boxplots, Violin plot basics, Streamplot and Lorenz attractor. For R, ggplot2 describes itself as “a system for declaratively creating graphics, based on The Grammar of Graphics.”
Install or access
Use the projects’ own documentation as the source for installation.
- matplotlib (Python). The official install page gives
python -m pip install -U pipfollowed bypython -m pip install -U matplotlib. The short form ispip install matplotlib. - ggplot2 (R). The official site gives
install.packages("tidyverse")orinstall.packages("ggplot2"). The development version installs withpak::pak("tidyverse/ggplot2").
The matplotlib gallery is at matplotlib.org/stable/gallery, and ggplot2’s reference pages are at ggplot2.tidyverse.org. For a walk through the Python import line itself, see import matplotlib.pyplot as plt: what it does.
Step-by-step: build a clear figure
The steps follow the order of the Ten Simple Rules: decide the message first, then pick the simplest chart that carries it, then tune it.
- Know your audience and identify your message (Rules 1 and 2). Write one sentence saying what the reader should conclude before you open any plotting software.
- Pick the simplest chart that conveys the message (Rule 7). The paper’s rule of thumb is to use the simplest type of plot that can convey your message, and it names pie charts and 3-D charts as poor choices for comparing quantities. To compare distributions across groups, a boxplot is a gallery chart type in both tools.
- Draw it. In matplotlib, the Boxplots gallery example calls
boxplot(data)on an Axes object. A minimal version, with placeholder numbers you replace with your own data:import matplotlib.pyplot as plt data = [[2.1, 2.4, 2.9, 3.1, 3.8], [3.0, 3.4, 3.9, 4.2, 5.1]] fig, ax = plt.subplots() ax.boxplot(data) ax.set_xlabel("Group") ax.set_ylabel("Measured value (units)") fig.savefig("figure.png", dpi=300)In R, the geom_boxplot reference page includes
ggplot(mpg, aes(class, hwy)) + geom_boxplot()using thempgdata set that ships with ggplot2:library(ggplot2) ggplot(mpg, aes(class, hwy)) + geom_boxplot() + labs(x = "Vehicle class", y = "Highway miles per gallon") ggsave("figure.png") - Do not trust the defaults (Rule 5). Change at least labels, units, size and colors so they serve this message. The paper says defaults are “good enough for any plot but they are best for none.”
- Use color effectively (Rule 6). For palettes in R, see ggplot color palettes: Brewer, Viridis and manual scales.
- Write the caption (Rule 4). The rule is titled “Captions Are Not Optional”. Write it for every figure you publish.
- Export for the medium (Rule 3). Adapt the figure to the support medium, such as a journal page or a slide.
Output and how to read it: a checklist for judging any example
Use these six checks, each drawn from a rule in the paper, to decide whether an example is worth imitating.
| Check | What to look for | Source rule |
|---|---|---|
| One clear message | You can state in a sentence what the figure shows. | Rule 2: Identify Your Message |
| Tuned, not default | Fonts, sizes, ticks and colors were chosen for this plot rather than left at the software’s settings. | Rule 5: Do Not Trust the Defaults |
| Color with a purpose | The colormap was chosen for the nature of the data (the paper’s Rule 5 discussion mentions choosing the best colormap for the data). | Rule 6: Use Color Effectively |
| Honest scales | Axes, ticks and labels show the full range of values where relevant; no automatic re-scaling that exaggerates differences. | Rule 7: Do Not Mislead the Reader |
| No chartjunk | No gratuitous backgrounds, useless grid lines, or overlapping legends and labels. | Rule 8: Avoid “Chartjunk” |
| Readable first | Readability and message come first; beauty is optional. | Rule 9: Message Trumps Beauty |
Two worked examples from the paper itself
The paper contains its own before-and-after figures. Its Figure 4 shows sine and cosine functions rendered by matplotlib with default settings, described as clear enough but visually improvable by tweaking settings. Its Figure 7 compares a poor design, in which seven overlapping curves, automatically chosen colors, an overlapping legend, too many ticks and a misaligned grid make the plot hard to read, with a better layout: the seven series split into seven small plots, labels placed on the left instead of a colored legend, x ticks reduced to three, and y ticks removed in favor of gray background boxes marking the range from -1 to +1. That redesign is a clean example of Rule 8 in practice, using the same area on the page.
The contrast case
Great examples are easier to recognise next to a failure. For a concrete failure with code to fix it, read bad data visualization example: truncated axes and how to fix them in code.
Troubleshooting
- The figure looks like every other default plot. The paper notes you can usually recognise the software from its default settings. Change size, font, colors and ticks deliberately (Rule 5).
- Differences look bigger than they are. If your software automatically re-scales values, the result can be visually misleading even when the labels are correct. Show the full range of values where relevant (Rule 7); the related guide linked above covers truncated axes.
- Curves, labels or the legend collide. This is the failure shown in the paper’s Figure 7. Split series into separate panels or label lines directly, and cut ticks that carry no information (Rule 8).
- You are tempted to copy a striking figure. Adapt it, do not copy it, and mind image copyright (Rule 9).
- Not sure which statistical chart fits your data. Start from the gallery section called Statistics in matplotlib, and for specific cases see volcano plots in RNA-seq or heatmaps in seaborn.
Free alternatives
| Tool | Language | Install (from the official docs) | Where to find examples |
|---|---|---|---|
| matplotlib | Python | python -m pip install -U matplotlib |
Official gallery, sections including Statistics, Color and Style sheets |
| ggplot2 | R | install.packages("ggplot2") |
Reference pages on ggplot2.tidyverse.org; R users can also read ggplots in R: build, style and save plots |
FAQ
What makes a data visualization good?
A good visualization delivers a clear message to a specific audience without misleading the reader. In the Ten Simple Rules, that means knowing your audience, identifying your message, not trusting software defaults, using color effectively, not misleading the reader, avoiding chartjunk, and letting message trump beauty.
Where can I find examples of data visualizations?
For code you can run, start with the official matplotlib gallery and the ggplot2 reference pages. For design judgment, read published figures in your own field’s literature, as Rule 9 suggests, and check each against the checklist above.
Are famous infographics good models for a research figure?
Not automatically. The paper observes that the boundaries between data visualization, infographics, design and art are thinning, and that many graphics put aesthetics before content. Judge by the checklist, not by how striking the graphic is.
Which tool should I use?
Rule 10 is titled “Get the Right Tool”. Use the tool your analysis already lives in: matplotlib if you work in Python, ggplot2 if you work in R.
Sources
Sources checked 2026-10-29.
- Rougier NP, Droettboom M, Bourne PE (2014). Ten Simple Rules for Better Figures. PLoS Computational Biology 10(9): e1003833. doi.org/10.1371/journal.pcbi.1003833
- Matplotlib documentation, Examples gallery: matplotlib.org/stable/gallery/index.html; Boxplots example: boxplot_demo; Installation: matplotlib.org/stable/install; savefig: pyplot.savefig
- ggplot2 home: ggplot2.tidyverse.org; geom_boxplot: reference/geom_boxplot; ggsave: reference/ggsave







