没用cmap时的方法需要循环设置label,例如 for color, i, target_name in zip(colors, [0, 1, 2], target_names): plt.scatter( X_r2[y == i, 0], X_r2[y == i, 1], alpha=0.8, color=color, label=target_name ) 使用cmap时一个plt.scatter()即
importmatplotlib.pyplotaspltimportnumpyasnp# 创建一个简单的数据集x=np.linspace(0,10,100)y=np.sin(x)# 使用 get_cmap 获取 'cool' 色彩映射cmap=plt.get_cmap('cool')# 使用 cool 色彩映射绘制彩色线条plt.scatter(x,y,c=y,cmap=cmap)plt.colorbar()plt.title('How2matplotlib.com - Cool Colorm...
y_values = [x ** 2 for x in x_values] # plt.scatter(x_values, y_values,c='red', s=50) ## 参数c表示红绿蓝3种颜色的分量 # plt.scatter(x_values, y_values,c=(0,0.5,0.2), s=50) ## 将参数c设置为一个y值的列表,使用参数cmap告诉plot使用哪个颜色映射 plt.scatter(x_values, y...
x_values = range(1, 1001) y_values = [x ** 2 for x in x_values] plt.style.use('seaborn') fig, ax = plt.subplots() # ax.scatter(x_values, y_values, c='red', s=10) # 参数c为要设置使用的颜色 # ax.scatter(x_values, y_values, c=(0.3, 0.2, 0.5), s=10) # RGB颜色...
需要有关使用cmap和保留功能的帮助ENPython 的关键数据结构是列表和元组。元组元素一旦设置,就无法更改。...
Scatterplot matrix demonstrating correlation between maximum CMAP negative peak amplitude and MHFMS scores with 95% density ellipse.Kathryn J. SwobodaCharles B. ScottThomas O. CrawfordLouise R. SimardSandra P. ReynaKristin J. KrosschellGyula Acsadi...
First we’ll plot a contourf plot using the standard Matlab functions. Without labeling the contour lines, it’s difficult to tell which values in the colorbar correspond to the color intervals in the contourf plot.count = 0; % Data [x,y] = meshgrid(linspace(0,1,100)); z = peaks...
(https://github.com/oldj/pyheatmap) 可以直接下载源码安装最新的版本,也可以通过pip或easy_install...
plt.scatter(x, y, s=area, alpha=0.5) 精致的曲线,半透明的配色。显出你那高贵冷艳的X格,最重要的是只需一行代码就能搞定。从此再也不用忍受 Matlab以及GNUPlot 中那蛋疼的配色了。 想画3D 数据?没有问题 (用mayavi可能更方便): ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)cset ...
colors = [cmap(i) for i in np.linspace(0, 1, len(x))] plt.scatter(x, y, c=colors) plt.show() ``` 在这个例子中,我们使用了get_cmap函数来获取'viridis'颜色映射对象。然后,我们使用linspace函数生成了一组等间距的数值,这些数值用来指定颜色映射的级别。接着,我们使用了列表推导式来生成一组颜...