Setting range of a colormap in Matplotlib

泄露秘密 提交于 2019-12-05 06:53:59

问题


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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/7574748/setting-range-of-a-colormap-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!