Publication-Ready Scientific Plots for Cell, Nature, and Science Journals
Create visually stunning, journal-quality figures with minimal code. Built on matplotlib, fully compatible with seaborn, and optimized for Adobe Illustrator.
Documentation Β· Examples Gallery Β· Report Bug Β· Request Feature
cnsplots is a Python visualization library designed specifically for creating publication-ready scientific figures. It takes care of the tedious styling details so you can focus on your science.
- π¨ Publication-Ready: Pre-configured styles matching Cell, Nature, and Science journal requirements
- π― Simple API: Create complex multi-panel figures with just a few lines of code
- π Precise Control: Specify dimensions in pixels, perfect for journal submission guidelines
- ποΈ Adobe Illustrator Compatible: SVG exports with editable fonts (no text-to-path conversion)
- π Statistical Integration: Built-in statistical tests and annotations
- π§ Highly Customizable: Full control over colors, fonts, and styling
- π Rich Color Palettes: Curated color schemes optimized for scientific visualization
- π§© Multi-Panel Support: Easy creation of complex figure layouts
Basic Plots
- Box plots, violin plots, bar plots, strip plots
- Scatter plots, line plots, regression plots
- Histograms, KDE plots, ridge plots
Scientific Plots
- Survival plots (Kaplan-Meier)
- Cumulative incidence plots
- ROC curves and forest plots
- Volcano plots and GSEA plots
- Confusion matrices
Specialized Plots
- Heatmaps with hierarchical clustering
- Dot plots for enrichment
- Venn diagrams and UpSet plots
- Sankey diagrams
- Pie and donut charts
- QQ plots and slope plots
Multiple curated palettes including:
- Qualitative: Cell, Nature, Science, Ecotyper1-6, Set1-3, Tableau, Bold
- Sequential: Parula, gnuplot, custom gradients
- Diverging: BlueRed, BuRd_custom, OrBu_custom
Create complex layouts with automatic panel labeling (A, B, C...):
import cnsplots as cns
mp = cns.multipanel(max_width=540)
# Panel A
mp.panel("A", height=150, width=150)
cns.boxplot(data=df1, x="group", y="value")
# Panel B
mp.panel("B", height=150, width=150)
cns.scatterplot(data=df2, x="x", y="y")
# Continues...pip install cnsplotsFirst install uv, then:
git clone https://github.com/faridrashidi/cnsplots
cd cnsplots
make installThis installs the package with its development and documentation extras. Core
scientific integrations such as scanpy, lifelines, and gseapy remain
runtime dependencies of cnsplots itself.
import cnsplots as cns
import seaborn as sns
# Load example data
df = sns.load_dataset("tips")
# Create a figure (height, width in pixels)
cns.figure(height=150, width=100)
# Create a publication-ready boxplot
cns.boxplot(data=df, x="day", y="total_bill")
# Save as vector graphic
cns.savefig("figure.svg")# Add statistical significance annotations
cns.figure(150, 150)
cns.boxplot(
data=df,
x="day",
y="total_bill",
pairs=[("Thur", "Fri"), ("Sat", "Sun")], # Compare these pairs
)
# Prints: P-values were determined by two-sided Mann-Whitney U test.# Use custom color palette
cns.figure(150, 200, color_cycle="Ecotyper1")
cns.violinplot(data=df, x="day", y="total_bill", hue="sex")Explore our comprehensive examples gallery featuring:
- π¦ Basic statistical plots
- 𧬠Genomics and bioinformatics visualizations
- π Time-series and survival analysis
- π― Machine learning results (ROC, confusion matrices)
- π¬ Multi-omics data visualization
- π¨ Custom color schemes and styling
Full documentation is available at cnsplots.farid.one
Specify sizes in pixels for precise control:
cns.figure(height=150, width=100) # Final canvas size is 150px Γ 100pxAccess curated color palettes:
# Qualitative palettes (for categorical data)
cns.figure(color_cycle="Ecotyper1") # Default, optimized for journals
cns.figure(color_cycle="Cell") # Custom Cell-inspired journal palette
cns.figure(color_cycle="Nature") # Nature-inspired journal palette
cns.figure(color_cycle="Science") # Science-inspired journal palette
cns.figure(color_cycle="Set1") # ColorBrewer Set1
# Sequential palettes (for continuous data)
cns.figure(color_map="parula") # MATLAB-style
cns.figure(color_map="gnuplot") # Default sequential
# Get individual colors
red = cns.RED
blue = cns.BLUEMany plot functions include built-in statistical testing:
# Boxplot with Mann-Whitney U test
cns.boxplot(data=df, x="group", y="value", pairs="all")
# Barplot with Welch's t-test
cns.barplot(data=df, x="group", y="value", pairs=[("A", "B")])
# Stackplot with Fisher's exact test
cns.stackplot(data=df, x="group", y="category", pairs=[("A", "B")])# SVG for vector graphics (recommended)
cns.savefig("figure.svg")
# High-resolution PNG
cns.savefig("figure.png")
# PDF with editable text
cns.savefig("figure.pdf")For Illustrator-optimized SVG post-processing, install MuPDF's mutool.
Without it, cns.savefig("figure.svg") falls back to a standard matplotlib SVG
and emits a warning instead of failing.
- Python β₯ 3.10
- Core: matplotlib, numpy, pandas, seaborn
- Included integrations: lifelines, gseapy, scanpy, and other plotting backends
- Optional external tool: MuPDF's
mutoolfor enhanced SVG post-processing
See pyproject.toml for complete dependency list.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
If you use cnsplots in your research, please cite:
@software{cnsplots,
author = {Rashidi, Farid},
title = {cnsplots: Publication-Ready Scientific Plots},
year = {2026},
url = {https://github.com/faridrashidi/cnsplots}
}This project is licensed under the BSD 3-Clause License - see the LICENSE.md file for details.
Built with:
- matplotlib - Core plotting library
- seaborn - Statistical visualizations
- lifelines - Survival analysis
- PyComplexHeatmap - Complex heatmaps
- UpSetPlot - Set intersections
Inspired by the visualization standards of Cell, Nature, and Science journals.
- π Documentation
- π Issue Tracker
- π¬ Discussions
- matplotlib - The foundation of Python plotting
- seaborn - Statistical data visualization
- plotnine - Grammar of graphics for Python
- altair - Declarative visualization
Made with β€οΈ for the scientific community
