Skip to content

Instantly share code, notes, and snippets.

@nschloe
Created February 16, 2022 21:48
Show Gist options
  • Save nschloe/f7bc5643d96d40b3b36a00ffdad99496 to your computer and use it in GitHub Desktop.
Save nschloe/f7bc5643d96d40b3b36a00ffdad99496 to your computer and use it in GitHub Desktop.
cplot demo
# https://gist.github.com/fredrik-johansson/4098b7aea7e0321ac50bb533a03515d0
import cplot
import matplotlib.pyplot as plt
import mpmath
import numpy as np
from mpmath import fp
def _wrap(fun):
def wrapped_fun(z):
z = np.asarray(z)
z_shape = z.shape
out = np.array([fun(complex(val)) for val in z.flatten()])
return out.reshape(z_shape)
return wrapped_fun
n = 300
plt.subplot(221)
cplot.plot(
_wrap(lambda z: (fp.qp(complex(z) ** 4) if abs(z) < 0.99 else np.nan)),
(-1.0, 1.0, n),
(-1.0, 1.0, n),
add_colorbars=False,
add_axes_labels=False,
)
plt.subplot(222)
cplot.plot(
_wrap(fp.zeta),
(-15.0, 15.0, n),
(-15.0, 15.0, n),
add_colorbars=False,
add_axes_labels=False,
)
plt.subplot(223)
f = lambda z: fp.gamma(complex(z))
cplot.plot(
_wrap(fp.gamma),
(-5.0, 5.0, n),
(-5.0, 5.0, n),
add_colorbars=False,
add_axes_labels=False,
)
plt.subplot(224)
f = lambda z: fp.erf(complex(z))
cplot.plot(
_wrap(fp.erf),
(-3.0, 3.0, n),
(-3.0, 3.0, n),
add_colorbars=False,
add_axes_labels=False,
)
plt.tight_layout()
# plt.show()
plt.savefig("demo2.png", dpi=200)
@nschloe
Copy link
Author

nschloe commented Feb 16, 2022

demo2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment