Skip to main content

Scientific Plots

Create and save plots in scientific style

Table of Contents

Overview

This python module includes useful methods and definitions for various python projects. The focus lies of on the automatic creation of a set of plots, which are designed to be used in scientific journals, dissertations and presentations. The most important components are the definitions of types compatible for numpy, located in types_.py, and the typing stubs in stubs/. These typing stubs are also distributed in this package.

Plotting

The easiest way to implement the plotting features provided by this library, is to use one of the predefined function in scientific_plots.default_plots. Alternatively, any plotting functions can be decorated by using the apply_styles decorator in scientific_plots.plot_settings.

For example, this could look like this:

import matplotlib.pyplot as plt
from scientific_plots.plot_settings import apply_styles

@apply_styles
def plot_something() -> None:
    """Example function."""
    plt.plot(...)
    ...
    plt.savefig("subfolder/your_plot_name.pdf")

The script will create a bunch of plots and place them in the given location next to your given path. Thus, it is advisable to create a different subfolder for new plots.

For three-dimensional plots, it is recommended to set the optional argument three_d of the decorator to true:

@apply_styles(three_d=True)
def plot_function():
    ...

Alternatively, this package provides default plot settings in the submodule default_plots. The provided function apply a default design, which should look good in most situations.

from scientific_plots.default_plots import plot

plot(x, y, "x_label", "y_label", "subfolder/filename.pdf")

Besides this simple plot, this library also provides the following default plots: plot_fit: Plot data and a fit of this data.

def fit_function(x):
    ...
    # fit some data
    ...
    return y

plot_fit(
    x, y, fit_function, "x_label", "y_label",
    "subfolder"/"filename.pdf")`

two_plots: Plot two curves sharing a single y-axis.

two_plots(
    x1, y1, "label1",
    x2, y2, "label2",
    "xlabel", "ylabel", "subfolder"/"filename".pdf)

two_axis_plots: Plot two curves with two y-axis in a single graph.

two_axis_plots(
    x1, y1, "label1",
    x2, y2, "label2",
    "xlabel", "ylabel1", "ylabel2",
    "subfolder"/"filename".pdf)

All of those functions have the following command-line arguments:

  • logscale: Plot the data double logarithmic.
  • single_log: Plot the x-axis logarithmic.
  • single_log_y: Plot the y-axis logarithmic.
  • xlim: Set the limits on the x-axis manually.
  • ylim: Set the limits on the y-axis manually.

Preview-Mode

It is possible to only create a single plot for every called plot function to save computation time. This 'preview' mode can be called by setting the following global variable in scientific_plots.plot_settings to true:

import scientifc_plots.plot_settings
scientifc_plots.plot_settings.PREVIEW = True

Types

Additional Vector like types for numpy-arrays are provided in scientifc_plots.types_. These types can be used for static type checking using mypy.

Typing Stubs

Addtional typing stubs for scipy, matplotlib and numba are provided and installed by this package. These packages do not provide type hints on their own.

Release files for scientific-plots 1.9.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scientific-plots 1.9.10
File Size Uploaded
scientific_plots-1.9.10.tar.gz 37.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scientific-plots 1.9.10
File Interpreter ABI Platform
scientific_plots-1.9.10-py3-none-any.whl Python 3 none any Details

Total release size: 79.1 kB

Release files / scientific_plots-1.9.10.tar.gz

Download URL scientific_plots-1.9.10.tar.gz
Size 37.4 kB
Tags Source
SHA-256 checksum
How to use checksums
01d0728bc58e3d75a602759cb30f3bfebf5098166aa944c81434a323c176ac1f
BLAKE2b-256 checksum
How to use checksums
d84d7dda8641cd70eaafb53f60b64fc6569fa73141f91ff4d27ce6ab793d14d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / scientific_plots-1.9.10-py3-none-any.whl

Download URL scientific_plots-1.9.10-py3-none-any.whl
Size 41.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d357a16855dd5658207b7fa6d0821e316f7116ef793fd95d74f4edfcd642e05
BLAKE2b-256 checksum
How to use checksums
23361eb8e3583d314de184ac58ec9e1e18d8f3160353e89f10f25a4fa2a9ac6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

1.9.10 This release

2 release files

1.9.9

2 release files

1.9.7

2 release files

1.9.6

2 release files

1.9.5

2 release files

1.9.4

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.0

2 release files

1.8.13

2 release files

1.8.12

2 release files

1.8.11

2 release files

1.8.10

2 release files

1.8.9

2 release files

1.8.8

2 release files

1.8.7

2 release files

1.8.6

2 release files

1.8.5

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.16

2 release files

1.7.15

2 release files

1.7.14

2 release files

1.7.13

2 release files

1.7.7

2 release files

1.7.6

2 release files

1.7.5

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.7

2 release files

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.4.9

2 release files

1.4.8

2 release files

1.4.7

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.14

2 release files

1.3.10

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.7

2 release files

1.3.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page