Skip to main content

Classical plots in one place.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aplot-0.2.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

aplot-0.2.0-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

Details for the file aplot-0.2.0.tar.gz.

File metadata

  • Download URL: aplot-0.2.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for aplot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 70e26e6a781972185cc0a2c9783ef0455719bda263f03b0588465ca2ab7cf494
MD5 8a99f2829d95715d37c96a9f25fc0b4a
BLAKE2b-256 f720ddb2d353fd9f005d8369d9358e45fc94fd0cc91c206c1b3d808551378adf

See more details on using hashes here.

File details

Details for the file aplot-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: aplot-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 33.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for aplot-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d18a0d41746e84512ad10fb2aaa87fb0de1eb10d08ed91a0c36556cc1a456e84
MD5 7c95096f3cbe22c0e292c44c4253b786
BLAKE2b-256 d47ebd43f909b0e5310a441454de5273339bbd64e2f51d7052b1e9b37fa6bc45

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page