Skip to content

Python · matplotlib · journal presets

Figures that are ready for the paper.

SecretPlots turns a pandas table into a publication-ready figure in a few readable lines. It sizes figures to journal columns, keeps text inside the journal's font limits, embeds the fonts, and adds the statistics reviewers ask for.

Make your first figure Browse the gallery

pip install SecretPlots

Six SecretPlots figures: box plot with significance, clustered heatmap, tumour growth curves, raincloud, volcano plot and regression.

From table to Nature figure

import numpy as np
import pandas as pd
import SecretPlots as sp

sp.use(preset="nature")   # 89 mm, 5–7 pt, fonts embedded

rng = np.random.default_rng(1)
cells = pd.DataFrame({
    "treatment": np.repeat(["Control", "siRNA", "siRNA + rescue"], 15),
    "area": np.concatenate([rng.normal(m, 45, 15) for m in (420, 290, 400)]),
})

(
    sp.box(cells, x="treatment", y="area")
    .points()
    .compare(ref="Control", correction="holm")
    .colors({"Control": "#BBBBBB", "siRNA": "#EE6677",
             "siRNA + rescue": "#4477AA"})
    .labels(x="", y="Cell area (µm²)")
)

Box plots of cell area with individual cells and Holm-corrected P values.

Then call .save("figure1.pdf"). The file is 89 mm wide with TrueType fonts embedded, the format Nature's production team asks for.

Why SecretPlots?

  • Journal presets


    Nature, Science, Cell, PNAS, IEEE, Springer, Elsevier and more: column widths, font limits, dpi and formats from the publishers' guidelines.

    Journal-ready figures

  • Statistics built in


    Significance brackets with Holm or Bonferroni correction, confidence bands, linear fits with R², KDEs and clustering, with the numbers available as tables.

    Box plots

  • Show every observation


    Points over boxes, individual trajectories under means, rainclouds and rug plots: the patterns reviewers expect for small samples.

    Violin & raincloud

  • Colour-blind safe


    Palettes and colormaps from SecretColors, with unsafe maps flagged and a greyscale print-bw theme.

    Presets & themes

  • Discoverable


    plot.options() lists every step you can chain; plot.options("legend") explains one. No need to search the web.

    Find any option

  • Honest by default


    Missing data raises instead of being silently dropped. Font and colour fallbacks are reported, and plot.explain() says where each style came from.

    Data handling

See all 14 examples with code

Choose a plot

Your question Plot Highlights
How do groups compare? Box · Violin / raincloud .points(), .compare(), .show_n(), split=True
What are the means and errors? Bar error="sd", hue=, stack=, .values()
How are two variables related? Scatter hue=, size=, .fit("linear", stats=True)
How does a response change over time? Line error="ci", units=, .errorbars(), .endlabels()
How do parts of a whole evolve? Area / fill between stack="percent", .split(), .gradient()
What does a distribution look like? Histogram stat="density", .kde(), .rug(), cumulative=
Where are the patterns in a matrix? Heatmap .scale("row"), .cluster(), .groups(), .tracks()