Skip to main content

Plot complex-valued functions

Project description

cplot

Plot complex-valued functions with style.

PyPi Version PyPI pyversions GitHub stars PyPi downloads

Discord

gh-actions codecov Code style: black

cplot helps plotting complex-valued functions in a visually appealing manner.

Install with

pip install cplot

and use as

import numpy as np

import cplot


def f(z):
    return np.sin(z ** 3) / z


plt = cplot.plot(
    f,
    (-2.0, +2.0),
    (-2.0, +2.0),
    400,
    # colorbars: bool = True,
    # abs_scaling="h-1.0",        # how to scale the lightness in domain coloring
    # colorspace: str = "cam16",  # ditto
    # abs/args contour lines:
    # contours=("auto", (-np.pi / 2, 0, np.pi / 2, np.pi)),
    # linecolors = "#a0a0a050",
    # linestyles = "solid",
    # linestyle_abs1 = "solid"
)
plt.show()

The plot consists of three building blocks:

  • domain coloring, i.e., mapping the absolute value to lightness and the complex argument to the chroma of the representing color
  • Contours of constant absolute value (the contour abs(z) == 1 is dashed, the other contours are at (2, 4, 8, etc. and 1/2, 1/4, 1/8, etc., respectively)
  • Contours along constant argument (angle). For arg(z) == 0, the color is green, for arg(z) == pi/2 it's orange, for arg(z) = -pi / 2 it's blue, and for arg(z) = pi it's pink

Other useful functions:

# There is a tripcolor function as well for triangulated 2D domains
cplot.tripcolor(triang, z)

# The function get_srgb1 returns the SRGB1 triple for every complex input value.
# (Accepts arrays, too.)
z = 2 + 5j
val = cplot.get_srgb1(z)

Gallery

All plots are created with default settings.

z**1 z**2 z**3
1/z z / abs(z) (z+1) / (z-1)
z ** z (1/z) ** z z ** (1/z)
np.sqrt z**(1/3) z**(1/4)
np.log np.exp exp(1/z)
np.sin np.cos np.tan
np.sinh np.cosh np.tanh
np.arcsin np.arccos np.arctan
sin(z) / z cos(z) / z tan(z) / z
scipy.special.gamma scipy.special.digamma mpmath.zeta
mpmath.siegeltheta mpmath.siegelz Riemann-Xi

Testing

To run the cplot unit tests, check out this repository and run

tox

Similar projects and further reading

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

cplot-0.5.1.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cplot-0.5.1-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file cplot-0.5.1.tar.gz.

File metadata

  • Download URL: cplot-0.5.1.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for cplot-0.5.1.tar.gz
Algorithm Hash digest
SHA256 233aa53aa6c6c2928fd442a92d67ed760593a3807ca28a71b064905a9e12e616
MD5 228e0a4f7bd60287e80b933018f80532
BLAKE2b-256 49a1b5aa35ef7357adb80e7dfe71d5a03fc54707854596b3cf557731739338ed

See more details on using hashes here.

File details

Details for the file cplot-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: cplot-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for cplot-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d92f7c3f83fca6b3019c0d881997db0e8b7d637eb8c059a47a6e0f93115a3352
MD5 cea183c032f9823240cbb47947c1da77
BLAKE2b-256 07e3e2c0dfd8d9ce00541f0623c5f4b9838759081aec366cabca3cfbd6caa9aa

See more details on using hashes here.

Supported by

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