栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Python / Matplotlib绘制基于颜色图的(极性)色轮

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Python / Matplotlib绘制基于颜色图的(极性)色轮

我发现的一种方法是生成颜色图,然后将其投影到极轴上。这是一个有效的示例-
尽管其中包括一个令人讨厌的骇客(明确注释)。我敢肯定有一种方法可以调整限制,或者(更难)编写自己的限制

Transform
来解决它,但是我还没有完全解决这个问题。我以为致电的范围
Normalize
会做到这一点,但显然不会。

import matplotlib.pyplot as pltimport numpy as npfrom matplotlib import cmimport matplotlib as mplfig = plt.figure()display_axes = fig.add_axes([0.1,0.1,0.8,0.8], projection='polar')display_axes._direction = 2*np.pi ## This is a nasty hack - using the hidden field to  ## multiply the values such that 1 become 2*pi ## this field is supposed to take values 1 or -1 only!!norm = mpl.colors.Normalize(0.0, 2*np.pi)# Plot the colorbar onto the polar axis# note - use orientation horizontal so that the gradient goes around# the wheel rather than centre outquant_steps = 2056cb = mpl.colorbar.Colorbarbase(display_axes, cmap=cm.get_cmap('hsv',quant_steps),  norm=norm,  orientation='horizontal')# aesthetics - get rid of border and axis labels  cb.outline.set_visible(False)display_axes.set_axis_off()plt.show() # Replace with plt.savefig if you want to save a file

这产生

如果您想要戒指而不是轮子,请在此之前

plt.show()
plt.savefig

display_axes.set_rlim([-1,1])

这给


按照@EelkeSpaak的注释-
如果按照OP将图形另存为SVG,则以下是处理所得图形的提示:所得SVG图像的小元素相互接触且不重叠。这会导致某些渲染器(Inkscape,Adobe
Reader,可能不在打印中)中的灰色线条模糊。一个简单的解决方案是使用例如Inkscape或Illustrator对每个单独的渐变元素应用较小的缩放比例(例如120%)。请注意,您必须将变换单独应用于每个元素(上述软件提供了自动执行此功能的功能),而不是整个图形,否则无效。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/647300.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号