Matplotlib 中颜色图的设置范围
我正在使用 matplotlib 绘制一个简单的图形:
cm=plt.get_cmap('Blues')
nx.draw_circular(G,
node_color='White',
edge_color=range(G.number_of_edges()),
edge_cmap=cm,
node_size=900,
width=4
)
我想在颜色图“蓝色”上设置一个范围,以删除绘图中不可见的白色。
请帮忙!
抱歉英语不好。
I'm using matplotlib to plot a simple graph:
cm=plt.get_cmap('Blues')
nx.draw_circular(G,
node_color='White',
edge_color=range(G.number_of_edges()),
edge_cmap=cm,
node_size=900,
width=4
)
I want to set a range on the colormap 'Blues' in such a way to delete the white color which is not visible in the draw.
Please help!
Sorry for bad english.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
范围(或规范化)实际上并不是颜色图,但通常作为使用颜色图绘制的函数中的一个功能来实现。例如,
imshow
使用vmin< /code> 和
vmax
,因此您可以尝试将它们用作
draw_circular
的关键字(我找不到文档),或者也许norm
。除此之外,您可以使用您想要的精确颜色排列来制作自己的颜色图。有很多关于如何制作自定义颜色图的示例,以及一些不同的方法可用。此处(a,b, c, d) 是一些可能对您有用的示例。
The range (or normilization) is not really a feature of the colormap, but is often implemented as a feature in the functions that plot using colormaps. For example,
imshow
usesvmin
andvmax
, so you might try using these as keywords withdraw_circular
(I can't find the documentation), or maybenorm
.Other than this, you can make your own colormap with exact color arrangement that you want. There are plenty of examples on how to make custom colormaps, and a few different approaches available. Here (a, b, c, d) are a few examples that might be useful to you.
我在尝试使用不同的颜色图绘制数据时遇到了这个问题:
很难判断哪个白色点属于哪个分布。我通过砍掉颜色图谱的较白部分解决了这个问题:
I ran into this problem trying to plot data with different colormaps:
It's hard to which of the whitish dots belong to which distribution. I solved this problem by chopping off the whiter parts of the colormap spectrum: