importmatplotlib.pyplotaspltimportnumpyasnp# 创建一个包含正负值的数据集x=np.linspace(-5,5,100)y=x**3# 使用 'RdBu' 发散色彩映射表plt.scatter(x,y,c=y,cmap='RdBu')plt.colorbar(label='y = x^3')plt.title('How2matplotlib.com: Div
定性色彩映射表(Qualitative colormaps) 让我们通过一个简单的例子来看看如何使用色彩映射表: importmatplotlib.pyplotaspltimportnumpyasnp# 创建数据x=np.linspace(0,10,100)y=np.sin(x)# 创建图形plt.figure(figsize=(10,6))plt.scatter(x,y,c=y,cmap='viridis')plt.colorbar(label='Sin(x)')plt.title...
importitertoolsimportmatplotlibasmplimportmatplotlib.pyplotasplt N =8*4+10l_styles = ['-','--','-.',':'] m_styles = ['','.','o','^','*'] colormap = mpl.cm.Dark2.colors# Qualitative colormapfori,(marker,linestyle,color)inzip(range(N),itertools.product(m_styles,l_styles, c...
https://matplotlib.org/stable/gallery/color/colormap_reference.html import matplotlib.pyplot as plt import numpy as np import matplotlib as mpl from matplotlib.colors import LinearSegmentedColormap, ListedColormap viridis = mpl.colormaps['viridis'] print(dir(viridis), 'viridis.colors', viridis.colo...
importmatplotlib.pyplotaspltfrommatplotlibimportcmplt.figure(dpi=150)##ListedColormap#取多种颜色plt.subplot(1,4,1)#plt.bar(range(5),range(1,6),color=plt.cm.Accent(range(5)))#plt.bar(range(5),range(1,6),color=plt.cm.get_cmap('Accent')(range(5)))plt.bar(range(5),range(1,6),...
一、获取colormap 首先,先看看如何从内置的 colormap 中获取新的 colormap 及其颜色值。 import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl from matplotlib import cm from matplotlib.colors importListedColormap, LinearSegmentedColormap ...
import matplotlib.pyplot as plt print("---获取所有颜色表colormaps---") print(matplotlib.colormaps) # 所有官方色带 rainbow = matplotlib.colormaps["rainbow"] 使用matplotlib.colormaps["色带名"]获取对应色带 这里是引入,后面会讲解具体使用方法和技巧 (二)自定义色带 from matplotlib...
import matplotlib.pyplot as plt cmaps=plt.colormaps() print(cmaps) 我们在quiver命令里面添加归一化参量,这个归一化参量主要是标注颜色的 C1D or 2D array-like, optional Numeric data that defines the arrow colors by colormapping via norm and cmap. ...
在Python Matplotlib 中的色彩图(Colormaps) importnumpyasnpimportmatplotlib.pyplotaspltx=np.arange(9)y=[9,2,8,4,5,7,6,8,7]plt.scatter(x, y, c=y, cmap="viridis")plt.xlabel("X")plt.ylabel("Y")plt.title("Scatter Plot with Virdis colormap")plt.colorbar()plt.show() ...
b:蓝色 g:绿色 r:红色 c:青色 m:红色 y:黄色 k:黑色 w:白色 具体颜色名称,如'red','blue' 评论 In [16]: import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl import matplotlib.cm as cm import matplotlib.colors as mcolors 收藏评论 连续colormap¶ 评论 1. 使用系统...