在 Matplotlib 中设置颜色图的范围 [英] Setting range of a colormap in Matplotlib

查看:50
本文介绍了在 Matplotlib 中设置颜色图的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 matplotlib 绘制一个简单的图形:

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.

请帮忙!

抱歉英语不好.

推荐答案

范围(或 规范化) 并不是颜色图的真正功能,但通常在使用颜色图进行绘图的函数中实现为功能.例如,imshow 使用 vminvmax,因此您可以尝试将这些作为关键字与 draw_circular 一起使用(我找不到文档),或者可能是 norm.

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 uses vmin and vmax, so you might try using these as keywords with draw_circular (I can't find the documentation), or maybe norm.

除此之外,您还可以根据自己的需要制作具有精确颜色排列的颜色图.有很多关于如何制作自定义颜色图的示例,以及一些可用的不同方法.这里(a, b, cd) 是一些可能的例子对你有用.

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.

这篇关于在 Matplotlib 中设置颜色图的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆