Setting range of a colormap in Matplotlib(在 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
使用 vmin
和 vmax
,因此您可以尝试将这些作为关键字与 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, c、d) 是一些可能的例子对你有用.
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 中设置颜色图的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Matplotlib 中设置颜色图的范围


基础教程推荐
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 筛选NumPy数组 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01