复值函数绘图工具
cplot的Python项目详细描述
使用样式绘制复杂值函数。
cplot有助于以直观的方式绘制复杂值函数。这个 一般的想法是将绝对值映射到亮度和复杂参数(即 “角度”)表示颜色的色度。这遵循domain coloring方法,也由 John D. Cook 还有伊莱亚斯·韦格特在书中的描述。
使用安装
pip3 install cplot --user
并用作
importcplotimportnumpycplot.show(numpy.tan,-5,+5,-5,+5,100,100)cplot.save_fig("out.png",numpy.tan,-5,+5,-5,+5,100,100)cplot.save_img("out.png",numpy.tan,-5,+5,-5,+5,100,100)# 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+5jval=cplot.get_srgb1(z)
所有函数都有可选参数(带默认值)
alpha=1# >= 0colorspace="cam16"# "cielab", "hsl"
alpha
可用于调整颜色的使用。小于1的值将添加更多颜色 有助于分离根和杆(仍然是黑白的, 分别)。alpha=0
完全忽略f(z)
的大小。colorspace
可以设置为hsl
,以获得常见的完全饱和、充满活力的 颜色。这通常是个坏主意,因为它会创建与 与基础数据。来自Wikipedia:Since the HSL color space is not perceptually uniform, one can see streaks of perceived brightness at yellow, cyan, and magenta (even though their absolute values are the same as red, green, and blue) and a halo around L = 1 / 2 . Use of the Lab color space corrects this, making the images more accurate, but also makes them more drab/pastel.
默认为^{
} ; 非常相似的是"cielab"
(这里没有显示)。
考虑测试函数(z ** 2 - 1) * (z - 2 - 1j) ** 2 / (z ** 2 + 2 + 2j)
:
^{ | ^{ | ^{ |
---|---|---|
所选择的表示方式使得
- 围绕0的值是black,
- infinity周围的值是white,
- +1周围的值是green,
- 围绕-1的值是deep purple,
- +i周围的值是blue,
- -i周围的值是orange。
(与下面的z1参考图比较。)
有了这个,就很容易看出一个函数有非常小和非常大的值,并且 零点和极点的多重性通过计数色轮立即被识别 绕过一个黑色或白色的点。
图库
所有绘图都是使用默认设置创建的。
^{ | ^{ | ^{ |
^{ | ^{ | ^{ |
^{ | ^{ | ^{ |
^{ | ^{ | ^{ |
^{ | ^{ | ^{ |
^{ | ^{ | ^{ |
^{ | ^{ | ^{ |
^{ | ^{ | ^{ |
测试
要运行cplot单元测试,请签出此存储库并键入
pytest
许可证
cplot在MIT license下发布。