All Projects β†’ nschloe β†’ cplot

nschloe / cplot

Licence: GPL-3.0 License
🌈 Plot complex functions

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to cplot

diofant
A Python CAS library
Stars: ✭ 61 (-18.67%)
Mutual labels:  science, mathematics
texfig
Utility to generate PGF vector files from Python's Matplotlib plots to use in LaTeX documents.
Stars: ✭ 58 (-22.67%)
Mutual labels:  matplotlib, plotting
2021-bordeaux-dataviz
Scientific Visualization Crash Course (Python & Matplotlib)
Stars: ✭ 20 (-73.33%)
Mutual labels:  matplotlib, plotting
Sage
Mirror of the Sage source tree -- please do not submit PRs here -- everything must be submitted via https://trac.sagemath.org/
Stars: ✭ 1,656 (+2108%)
Mutual labels:  science, mathematics
expyplot
Matplotlib for Elixir
Stars: ✭ 27 (-64%)
Mutual labels:  matplotlib, plotting
Python Quickui
Scientific One-Liner Interactive GUI Library
Stars: ✭ 153 (+104%)
Mutual labels:  science, matplotlib
PyCORN
A script to extract data from Γ„KTA/UNICORN result-files (.res)
Stars: ✭ 30 (-60%)
Mutual labels:  science, plotting
Matplotlib Scalebar
Provides a new artist for matplotlib to display a scale bar, aka micron bar.
Stars: ✭ 58 (-22.67%)
Mutual labels:  science, matplotlib
planetMagFields
Routines to plot magnetic fields of planets in our solar system
Stars: ✭ 27 (-64%)
Mutual labels:  matplotlib, plotting
dufte
πŸ“ˆ Minimalistic Matplotlib style
Stars: ✭ 196 (+161.33%)
Mutual labels:  matplotlib, plotting
geneview
Genomics data visualization in Python by using matplotlib.
Stars: ✭ 38 (-49.33%)
Mutual labels:  matplotlib, plotting
SciPlot-PyQt
A Matplotlib-wrapped user-interface for creating and editing publication-ready images and plots
Stars: ✭ 32 (-57.33%)
Mutual labels:  matplotlib, plotting
Plotters
A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely πŸ¦€ πŸ“ˆπŸš€
Stars: ✭ 1,287 (+1616%)
Mutual labels:  science, plotting
Stdlib
✨ Standard library for JavaScript and Node.js. ✨
Stars: ✭ 2,749 (+3565.33%)
Mutual labels:  science, mathematics
Silx
silx toolkit
Stars: ✭ 69 (-8%)
Mutual labels:  science, plotting
EOmaps
A library to create interactive maps of geographical datasets
Stars: ✭ 193 (+157.33%)
Mutual labels:  matplotlib, plotting
Librmath.js
Javascript Pure Implementation of Statistical R "core" numerical libRmath.so
Stars: ✭ 425 (+466.67%)
Mutual labels:  science, mathematics
Latex Examples
Examples for the usage of LaTeX
Stars: ✭ 1,032 (+1276%)
Mutual labels:  science, mathematics
plottr
A flexible plotting and data analysis tool.
Stars: ✭ 32 (-57.33%)
Mutual labels:  science, plotting
joypy
Joyplots in Python with matplotlib & pandas πŸ“ˆ
Stars: ✭ 418 (+457.33%)
Mutual labels:  matplotlib, plotting

cplot

Plot complex-valued functions with style.

PyPi Version PyPI pyversions DOI GitHub stars 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, 400),
    (-2.0, +2.0, 400),
    # abs_scaling=lambda x: x / (x + 1),  # how to scale the lightness in domain coloring
    # contours_abs=2.0,
    # contours_arg=(-np.pi / 2, 0, np.pi / 2, np.pi),
    # emphasize_abs_contour_1: bool = True,
    # colorspace: str = "cam16",
    # add_colorbars: bool = True,
    # add_axes_labels: bool = True,
    # saturation_adjustment: float = 1.28,
    # min_contour_length = None,
)
plt.show()

Historically, plotting of complex functions was in one of three ways

Only show the absolute value; sometimes as a 3D plot Only show the phase/the argument in a color wheel (phase portrait) Show contour lines for both arg and abs

Combining all three of them gives you a cplot:

See also Wikipedia: Domain coloring.

Features of this software:

  • By default, cplot uses a perceptually uniform color space for the argument colors. This avoids streaks of colors occurring with other color spaces, e.g., HSL.
  • The contour abs(z) == 1 is emphasized, other abs contours are at 2, 4, 8, etc. and 1/2, 1/4, 1/8, etc., respectively. This makes it easy to tell the absolte value precisely.
  • For arg(z) == 0, the color is green, for arg(z) == pi/2 it's blue, for arg(z) = -pi / 2 it's orange, 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)

Riemann sphere

cplot can also plot functions on the Riemann sphere, a mapping of the complex plane to the unit ball.

import cplot
import numpy as np

cplot.riemann_sphere(np.log)

Gallery

This way to the gallery!

cplot

Testing

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

tox

Similar projects and further reading

License

This software is published under the GPL-3.0 license. In cases where the constraints of the GPL prevent you from using this software, feel free contact the author.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].