Skip to main content

APlot. Try to make Matplotlib great again.


Pypi Python 3.7+ License Code style: black CodeFactor Codecov Download Stats Documentation

aPlot - is a wrapper around Matplotlib that reduces the code required for plotting.

Motivation

APlot is a wrapper around Matplotlib that reduces the code required for plotting. It makes the code shorter and more pleasant, while still maintaining generality.

Currently plotting with matplotlib is a nightmare. Normally there are so many line to plot a simple plot. Take as an example your code for plotting on grid 2x2 and count how make duplication information you have. So this library is a way how to write less to have the same plots. It’s a wrapper around Matplotlib and therefore you still have all function from it, so don’t worry to not have some functionality. But the main changes are the following:

  • Every plot or set method on axes return the axes itself. Which allows your to stack command and
  • You can create the list of the axes and do manipulations on a list. Like setting labels or plotting some data, which reduce by a lot the repeating information.
  • As usual it’s typed as well as original matplotlib, there for you have hints to allow you very smooth manipulation.

Here's a simple example demonstrating how this package can significantly reduce the number of lines in your code. In this example, it went from 13 to 5 lines, remained perfectly readable and potentially prettier.

Matplotlib code:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(2, 2)
x = np.linspace(0, 2 * np.pi, 100)
z = np.sin(x) + 1j * np.cos(x)

axes[0][0].plot(x, np.real(z))
axes[0][0].set_ylabel("Real")
axes[1][0].plot(x, np.imag(z))
axes[1][0].set_ylabel("Imag")
axes[0][1].plot(x, np.abs(z))
axes[0][1].set_ylabel("Amp")
axes[1][1].plot(x, np.unwrap(np.angle(z)))
axes[1][1].set_ylabel("Phase")
for axes_row in axes:
    for ax in axes_row:
        ax.set(xlabel="Time (s)")
fig.suptitle("Complex Signal")
fig.tight_layout()

APlot compact code

import aplot as ap
x = np.linspace(0, 2 * np.pi, 100)
z = np.sin(x) + 1j * np.cos(x)

axes = (
    ap.axs(2, 2)
    .plot(x, [[np.real(z), np.abs(z)], [np.imag(z), np.unwrap(np.angle(z))]])
    .suptitle("Complex Signal")
    .set(xlabel="Time (s)", ylabel=[["Real", "Abs"], ["Imag", "Phase"]])
    .tight_layout()
)

You can also access the axes as usual.

axes = (
    ap.axs(2, 2)
    .suptitle("Complex Signal")
    .set(xlabel="Time (s)", ylabel=[["Real", "Abs"], ["Imag", "Phase"]])
    .tight_layout()
)
axes[0].plot(x, [np.real(z), np.abs(z)])
axes[1][0].plot(x, np.imag(z))
axes[1][1].plot(x, np.unwrap(np.angle(z)))

You can use autoaxis method to let is name the axis for your draft plots

axes = (
    ap.axs(2, 2)
    .plot(x, [[np.real(z), np.abs(z)], [np.imag(z), np.unwrap(np.angle(z))]])
    .suptitle("Complex Signal")
    .autoaxis()
    .tight_layout()
)

Install

pip install aplot

For more installation details, please refer to the How to install

How to use

For further insight, please refer to the First Steps guide

Release files for aplot 0.2.0

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

Source distribution (sdist)

Source distribution for aplot 0.2.0
File Size Uploaded
aplot-0.2.0.tar.gz 29.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aplot 0.2.0
File Interpreter ABI Platform
aplot-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 63.1 kB

Release files / aplot-0.2.0.tar.gz

Download URL aplot-0.2.0.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
70e26e6a781972185cc0a2c9783ef0455719bda263f03b0588465ca2ab7cf494
BLAKE2b-256 checksum
How to use checksums
f720ddb2d353fd9f005d8369d9358e45fc94fd0cc91c206c1b3d808551378adf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / aplot-0.2.0-py3-none-any.whl

Download URL aplot-0.2.0-py3-none-any.whl
Size 33.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d18a0d41746e84512ad10fb2aaa87fb0de1eb10d08ed91a0c36556cc1a456e84
BLAKE2b-256 checksum
How to use checksums
d47ebd43f909b0e5310a441454de5273339bbd64e2f51d7052b1e9b37fa6bc45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.1

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