Created
February 16, 2022 21:48
-
-
Save nschloe/f7bc5643d96d40b3b36a00ffdad99496 to your computer and use it in GitHub Desktop.
cplot demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Author
nschloe
commented
Feb 16, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment