Get unlimited access to the best of Medium for less than $1/week.

TuePlots: Publication-ready Plots with Ease

Jogendragangwar
10 min read1 hour ago

In scientific publishing, creating high-quality, consistent plots is a real challenge. Formatting figures to meet journal requirements is often exhausting and a lot time-consuming. That’s where the role of Tueplots comes in! This Python library makes things easier like generating publication-ready figures that follow specific journal styles and also save our valuable time.

This is designed specifically for professional works like scientific papers — especially those using LaTeX — Tueplots provides pre-configured settings for Matplotlib, Which ensures consistency in font sizes, aspect ratios, and line widths, so our figures meet formatting standards without much irregularities and hassle.

Generally, professional workers struggle with fine-tuning figures to match strict academic guidelines. Tueplots takes care of this by automating the process, allowing us to create professional, compliant plots with minimal effort.

Installation and Setup

We can install TuePlots using pip. by opening terminal or command prompt and running:

pip install tueplots

if we need to install it in Jupyter Notebook, then we can use:

pip install tueplots jupyter

After installation, check if the tueplots is correctly installed by running:

import tueplots
print(tueplots._version_)

if no error occurs and it displays the version number, the installation is successful.

To update tueplots to the latest version, we can use:

pip install --upgrade tueplots

1️⃣Apply Pre-Configured Formatting for Research Papers

Tueplots provides ready-made formatting for popular conferences and journals.

Here are some supported Journals & Conferences:

  • NeurIPS (Neural Information Processing Systems)
  • ICML (International Conference on Machine Learning)
  • JMLR (Journal of Machine Learning Research)

Example usage:

from tueplots import bundles
import matplotlib.pyplot as plt

plt.rcParams.update(bundles.neurips2023()) # Apply NeurIPS 2023 style
plt.rcParams.update(bundles.icml2022()) # Apply ICML 2022 style
plt.rcParams.update(bundles.jmlr2001()) # Apply JMLR 2001 style

2️⃣ Customize Figure Sizes for Publications

We need figures in specific dimensions for better readability and to make our task easier and smooth.

We can:

✔ Set full-page width figures
✔ Use half-column width for compact plots

Another example usage:

from tueplots import figsizes

plt.rcParams.update(figsizes.neurips2023()) # Default NeurIPS size
plt.rcParams.update(figsizes.icml2022_half()) # Half-column ICML figure
plt.rcParams.update(figsizes.icml2022_full()) # Full-page ICML figure

3️⃣ We also can adjust Font Sizes to Match Journal Guidelines

Different journals have specific font size requirements for:
✔ Axis labels
✔ Titles
✔ Legends
✔ Tick labels

Example usage:

from tueplots import fontsizes

plt.rcParams.update(fontsizes.neurips2023()) # NeurIPS font sizes
plt.rcParams.update(fontsizes.icml2022()) # ICML font sizes
plt.rcParams.update(fontsizes.jmlr2001()) # JMLR font sizes

5️⃣ We should use Readable & Accessible Color Schemes

Scientific figures must be clear and readable, even for colorblind readers.

Here are some of the available Color Schemes:

Colorblind-friendly palette (colors.colorblind())
NeurIPS 2023 colors (colors.neurips2023())
ICML 2022 colors (colors.icml2022())

Example usage:

from tueplots import colors

plt.rcParams.update(colors.colorblind()) # Use colorblind-friendly colors
plt.rcParams.update(colors.neurips2023()) # Use NeurIPS 2023 color scheme
plt.rcParams.update(colors.icml2022()) # Use ICML 2022 color scheme

6️⃣ We should customize Axis Properties for Better Readability

This should be done because good axis formatting improves readability in scientific plots.

We Can:

✔ Enable gridlines (axes.grid())
✔ Customize tick formatting (axes.ticks())
✔ Adjust axis spine thickness (axes.spines())

Example usage:

from tueplots import axes

plt.rcParams.update(axes.grid()) # Enable gridlines
plt.rcParams.update(axes.ticks()) # Customize ticks
plt.rcParams.update(axes.spines()) # Adjust axis spines

7️⃣ Generating Publication-Ready Figures in One Go

Tueplots allows us to combine multiple settings for an optimized figure.

import matplotlib.pyplot as plt
import numpy as np
from tueplots import bundles, figsizes, fontsizes, markers, colors, axes

# Apply all formatting at once
plt.rcParams.update(bundles.neurips2023()) # NeurIPS 2023 style
plt.rcParams.update(figsizes.neurips2023()) # Set figure size
plt.rcParams.update(fontsizes.neurips2023()) # Set font sizes
plt.rcParams.update(markers.circle()) # Use circle markers
plt.rcParams.update(colors.colorblind()) # Apply colorblind-friendly colors
plt.rcParams.update(axes.grid()) # Enable gridlines

x = np.linspace(0, 10, 100)
y = np.sin(x)

fig, ax = plt.subplots()
ax.plot(x, y, label="Sine Wave")

ax.set_xlabel("X-axis")
ax.set_ylabel("Y-axis")
ax.set_title("Formatted Plot with Tueplots")
ax.legend()


plt.show()
  • matplotlib.pyplot → Used for creating plots and visualizations.
  • numpy → Helps generate numerical data (like arrays).
  • tueplots → This is the main library we’re using to style the plots professionally. It ensures that the figure matches the formatting of research papers and other professional documents.
  • bundles.neurips2023() → This applies the default style for NeurIPS (a research conference). It automatically adjusts font sizes, and margins, and makes the code things more simple and cool.
  • figsizes.neurips2023() → This makes sure the plot is the correct size for a NeurIPS paper.
  • fontsizes.neurips2023() → Ensures all text (titles, labels, etc.) is sized correctly.
  • markers.circle() → Sets the style of data points in the plot to circle markers.
  • colors.colorblind() → Uses a color palette that’s easy to distinguish, even for colorblind readers.
  • axes.grid() → Turns on gridlines to make the plot easier to read
  • np.linspace(0, 10, 100) → Generates 100 points evenly spaced between 0 and 10.
  • np.sin(x) → Calculates the sine of each value in x (used to plot a sine wave)
  • plt.subplots() → Creates a figure (fig) and an axis (ax) where we can draw our plot.
  • ax.plot(x, y, label="Sine Wave") → Plots the sine wave and labels it as "Sine Wave"
  • ax.set_xlabel("X-axis") → Labels the x-axis as "X-axis".
  • ax.set_ylabel("Y-axis") → Labels the y-axis as "Y-axis".
  • ax.set_title("Formatted Plot with Tueplots") → Adds a title to the plot.
  • ax.legend() → Displays the legend (which contains the label "Sine Wave")
  • plt.show() → Displays the plot on the screen.

8️⃣ Export Figures in High Quality for Papers & Presentations

Once our plot is formatted, we may need to export it as a high-quality file for submission.

Supported Formats:

PDF (Best for LaTeX papers)
PNG (For presentations)
SVG (For vector graphics

example usage:

plt.savefig("figure.pdf", bbox_inches="tight")  # Save as PDF
plt.savefig("figure.png", dpi=300) # Save as high-res PNG
plt.savefig("figure.svg") # Save as vector graphic

9️⃣ Seamless Integration with LaTeX for Research Papers

Tueplots ensures that figures match the font style of LaTeX papers

example usage:

import matplotlib as mpl

mpl.rcParams["text.usetex"] = True # Enable LaTeX rendering

10️⃣ Automatically Ensure Consistent Formatting Across All Figures

Instead of setting configurations for each plot manually, we can apply Tueplots globally for all figures in a script.

example usage:

import matplotlib.pyplot as plt

plt.rcParams.update(bundles.neurips2023()) # Apply formatting globally

This ensures all figures in our research paper look consistent

Summary of Tueplots Functions

Predefined Stylesbundles.neurips2023(), bundles.icml2022(), bundles.jmlr2001()

Figure Sizesfigsizes.neurips2023(), figsizes.icml2022_half(), figsizes.icml2022_full()

Font Sizesfontsizes.neurips2023(), fontsizes.icml2022(), fontsizes.jmlr2001()

Markersmarkers.circle(), markers.triangle(), markers.square()

Colorscolors.colorblind(), colors.neurips2023(), colors.icml2022()

Axes Customizationaxes.grid(), axes.ticks(), axes.spines()

With Tueplots, you can create research-ready plots with just a few lines of code!

example usage:

custom figure size and a different journal style

# Example: Using a custom figure size and a different journal style
import matplotlib.pyplot as plt
import numpy as np
import tueplots.bundles as bundles


x = np.linspace(0, 5, 50)
y = x**3 - 5*x**2 + 2*x + 7

# Create a plot with a specific figure size, and apply a journal style.
with plt.rc_context(bundles.neurips()):
fig, ax = plt.subplots(figsize=(5, 3))

ax.plot(x, y)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_title("Polynomial Function")
fig.tight_layout()


plt.show()
  • matplotlib.pyplot → Used for creating the plot.
  • numpy → Helps generate numerical data.
  • tueplots.bundles → Provides pre-configured styles for different academic journals and conferences (like NeurIPS).
  • np.linspace(0, 5, 50) → Creates 50 equally spaced points between 0 and 5.
  • y = x**3 - 5*x**2 + 2*x + 7 → Defines a polynomial function (y = x³ - 5x² + 2x + 7).
  • plt.rc_context(bundles.neurips()) → Temporarily applies the NeurIPS journal formatting.
  • fig, ax = plt.subplots(figsize=(5, 3)) → Creates a plot with a custom figure size (5 inches wide, 3 inches tall)
  • ax.plot(x, y) → Plots the polynomial function.
  • ax.set_xlabel("x") → Labels the x-axis as "x".
  • ax.set_ylabel("y") → Labels the y-axis as "y".
  • ax.set_title("Polynomial Function") → Sets the title of the plot
  • fig.tight_layout() → Automatically adjusts spacing to prevent labels from overlapping.
  • plt.show() → Displays the plot on the screen

Choosing the correct fonts

  • matplotlib.pyplot: The standard plotting library in Python.
  • tueplots.figsizes: A module for setting standardized figure sizes for different conferences (e.g., ICML, NeurIPS, IEEE).
  • tueplots.fonts: A module that provides pre-configured font settings to match academic publishing standards
plt.rcParams.update({"figure.dpi": 150})
  • Sets the DPI (dots per inch) to 150, which improves plot clarity.
  • Useful when exporting figures for papers, presentations, or journals
plt.rcParams.update(figsizes.icml2022_half())
  • This sets the figure dimensions to match the half-column width format required by the ICML 2022 conference.
  • Ensures consistency with other figures in an ICML paper.
fonts.neurips2021()
  • This function retrieves the recommended font settings for NeurIPS 2021.
  • However, it does NOT automatically apply them. You should update plt.rcParams manually like this:
fig, ax = plt.subplots()
  • Creates a new figure (fig) and a set of axes (ax) for plotting.
  • This is the standard way to create plots in Matplotlib
ax.plot([1.0, 2.0], [3.0, 4.0])
  • Plots a single line connecting the points (1.0, 3.0) and (2.0, 4.0).
  • Uses default Matplotlib settings for line color, width, and style.
  • Sets the title of the plot to "Title"
  • $\int f(x) dx$ is rendered as: integration of f(X) wrt dx.
  • This uses LaTeX-style math notation
ax.set_ylabel("ylabel $x \sim \mathcal{N}(x)$")
  • Sets the y-axis label with a Gaussian distribution expression:
  • $x \sim \mathcal{N}(x)$ is rendered as: x∼N(x)
  • \mathcal{N}(x) represents the normal distribution (Gaussian distribution) in LaTeX

Styling figure axis

  • matplotlib.pyplot: The core library for creating plots in Python.
  • tueplots.axes: A module in Tueplots that provides pre-defined settings for axis formatting in research-style figures.
plt.rcParams.update({"figure.dpi": 150})
  • This sets the DPI (dots per inch) of all plots to 150, which improves clarity.
  • High DPI is useful for exporting figures for research papers, making them sharper and more readable
  • This line does nothing as written because axes.lines() simply returns a dictionary of recommended settings.
  • If you want to apply those settings, you should use
  • Purpose of axes.lines():
  • Adjusts line width, marker size, and opacity.
  • Ensures consistency in scientific publications
  • plt.subplots() creates a figure (fig) and a set of axes (ax).
  • This prepares a plotting canvas where data will be displayed
ax.plot([1.0, 2.0], [3.0, 4.0])
  • Plots a simple line connecting the points (1.0, 3.0) and (2.0, 4.0).
  • Uses default line settings, which can be further customized
  • Renders the figure and displays it on the screen

Creating color-cycles

  • matplotlib.pyplot: Standard Python library for plotting.
  • numpy: Used for numerical computations (generates x-values for sine waves).
  • tueplots.cycler: Helps customize plot styles with predefined color cycles.
  • tueplots.constants.markers: Provides predefined marker styles for better visualization.
  • tueplots.constants.color.palettes: Contains predefined color palette
plt.rcParams.update({"figure.dpi": 150})
  • Sets the figure DPI (dots per inch) to 150 for better clarity and high-quality output
x = np.linspace(0, np.pi, 20)
  • Creates an array of 20 evenly spaced points between 0 and π.
  • These points serve as the x-values for plotting sine waves
offsets = np.linspace(0, 2 * np.pi, 8, endpoint=False)
  • Creates 8 evenly spaced phase shifts from 0 to (excluding endpoint).
  • These offsets shift each sine wave horizontally
  • Creates a list of sine wave values with different phase shifts.
  • For each phi in offsets, it calculates sin(x + phi)
  • Loops through all sine wave values (yy) and plots each one.
  • linewidth=3 makes the lines thicker for better visibility

Conclusion

Key Features & Explanation:

Why Use Tueplots?

Formatting figures for academic papers can be a point for worry, but Tueplots makes it simple. Here’s why it stands out:

  • Predefined Journal Styles — No more struggling with formatting! Tueplots includes ready-made styles for major journals like ACM and IEEE, ensuring the figures meet to exact specifications.
  • Easy to Use — With just a few lines of code, we can apply professional formatting to the Matplotlib plots.
  • Seamless Matplotlib Integration — Since it works directly with Matplotlib, so, we don’t need to learn a new tool — just enhance what we already use.
  • Customizable Options — While the default styles cover most needs, we can easily tweak figure dimensions, fonts, line widths, and more to suit our specific requirements.

Key Features at a Glance

✔️ LaTeX Compatibility — Our figures will blend seamlessly into LaTeX documents with consistent fonts and formatting.
✔️ Customizable Design — Adjust figure styles effortlessly to match publication guidelines.
✔️ Professional-Quality Output — Ensures our figures are clear, readable, and ready for publication.
✔️ Easy Setup — Works as a simple add-on to Matplotlib, requiring minimal configuration.
✔️ Consistent Formatting — Helps maintain a uniform look across all your figures.

With Tueplots, we can spend less time formatting and more time focusing on our research. Say goodbye to tedious figure adjustments and hello to clean, publication-ready visuals!

Strengths:

Saves Time: Automates figure formatting, reducing manual adjustments.

Professional Output: Ensures high-quality, publication-ready visuals.

Easy Integration: Works seamlessly with Matplotlib and LaTeX.

Customizable: Allows fine-tuning of figure aesthetics to meet specific journal or conference requirements.

Consistent Formatting: Helps maintain a uniform style across multiple figures in a research paper

Academic Research: Creating figures for conferences like NeurIPS, ICML, JMLR, etc.

Thesis & Dissertations: Ensuring polished and consistent visual presentation.

Technical Reports: Enhancing clarity and readability of scientific data.

Journal Publications: Meeting strict formatting requirements with minimal effort.

With Tueplots, we can focus on our research while ensuring our figures look clean, professional, and publication-ready effortlessly!

Summary: What We Can Do with Tueplots

Pre-configured styles Use Neur IPS, ICML, or JMLR styles

Custom figure sizes Adjust figure width and height for papers

Adjust font sizes Match journal formatting rules

Change marker styles Improve data point visibility

Use better colors Colorblind-friendly & research-friendly colors

Customize axes Gridlines, tick marks, and spines

Export in high quality Save as PDF, PNG, or SVG

LaTeX integration Ensure figures match LaTeX document fonts

Apply global formatting Automatically apply settings to all plots

References & Further Reading

https://r.search.yahoo.com/_ylt=AwrPrmdogLxnUUAPRKC7HAx.;_ylu=Y29sbwNzZzMEcG9zAzMEdnRpZAMEc2VjA3Ny/RV=2/RE=1741616489/RO=10/RU=https%3a%2f%2fgithub.com%2fpnkraemer%2ftueplots/RK=2/RS=GctenxUBx4D8iw_d_U6wrS4F.Ng-

https://r.search.yahoo.com/_ylt=AwrPrmdogLxnUUAPRaC7HAx.;_ylu=Y29sbwNzZzMEcG9zAzQEdnRpZAMEc2VjA3Ny/RV=2/RE=1741616489/RO=10/RU=https%3a%2f%2fgithub.com%2fpnkraemer%2ftueplots%2fblob%2fmain%2fdocs%2fsource%2fgetting_started%2fusage_example.md/RK=2/RS=0zzO3JdNhrUMeEW4cc7d2nvzvLY-

https://r.search.yahoo.com/_ylt=AwrPrmdogLxnUUAPRqC7HAx.;_ylu=Y29sbwNzZzMEcG9zAzUEdnRpZAMEc2VjA3Ny/RV=2/RE=1741616489/RO=10/RU=https%3a%2f%2ftueplots.readthedocs.io%2fen%2flatest%2findex.html/RK=2/RS=DPw7znm7rwhTuYoyAMODueqFQOk-

https://tueplots.readthedocs.io/_/downloads/en/latest/pdf/