如果想在图中包含更多信息,可以使用颜色、大小和形状来区分它们 通过颜色区分 使用violinplot函数时,可以通过hue参数按性别(sex)给图着色 可以为“小提琴”的左右两半着不同颜色,用于区分性别... 其它绘图函数中也存在hue参数 scatter = sns.lmplot(x='total_bill',y='tip',data = tips,hue='sex
11],'b*')# bluestar# 设定标签与上限ax1.set_title('Scatterplot Greendots');ax2.set_title('...
用于散点图的函数是“pl .scatter()” 自定义: scatter()函数具有以下参数,用于配置绘图。 size – 设置点的大小 color –设置点的颜色 marker – 标记的类型 alpha – 点的透明度 norm –规范化数据(将数据归一化0至1) 例子: # let's create a simple scatter plot # generate the data with random num...
plt.scatter(x, y, size, colour) plt.colorbar() plt.show() 1. 2. 3. 4. 5. 6. 7. 8. 上面的代码大量的用到了 np.random.rand(1000),原因是我们绘图的数据都是随机产生的。 同前面一样我们用到了 scatter() 函数,但是这次我们传入了另外的两个参数,分别为所绘点的大小和颜色。通过这种方式使...
colour=np.arctan2(y,x)# 生成每个点的颜色大小 plt.scatter(x,y,s=size,c=colour) plt.colorbar()# 添加颜色栏 # plt.figure(12) defpie_plot(): plt.subplot(323) # plt.plot(t1, f(t1), 'bo', t2, f(t2), 'r--') labels='Frogs','Hogs','Dogs','Logs' ...
scatter(tl_sub_x, np.zeros(len(tl_sub_x)), s=50, c='darkmagenta',zorder=4) # Date Text for x, date in zip(tl_x, tl_dates): ax.text(x, -0.55, date, ha='center', fontfamily='serif', fontweight='bold', color='royalblue',fontsize=12) # Stemplot : vertical line levels ...
plt.scatter(x,y) plt.show() 正如上面代码所示,你只需要调用scatter()函数并传入两个分别代表 x 坐标和 y 坐标的数组。注意,我们通过plot命令并将线的样式设置为'bo'也可以实现同样的效果。 最后你会得到类似下面的无线图形: 彩色映射散点图 另一种你可能用到的图形是彩色映射散点图。这里我们会根据数据的...
# Plot a sin curve using the x and y axes. x = np.linspace(0, 1, 100) y = np.sin(x * 2 * np.pi) / 2 + 0.5 ax.plot(x, y, zs=0, zdir='z', label='curve in (x,y)') # Plot scatterplot data (20 2D points per colour) on the x and z axes. colors = ('r',...
To plot a contour plot, usecontour()function. To add x-axis labels, usexlabel()function. To add y-axis label, useylabel()function. To display a plot, useshow()function. plt.contour() Read:Matplotlib 3D scatter Matplotlib 2d color surface plot ...
plt.scatter(x_axis2, y_axis2, color='darkred', marker='x', label="item 2") plt.xlabel("Time (years)") plt.ylabel("Price (dollars)") plt.grid(True) plt.legend() plt.show() The chart displays two data sets. We distinguish between them by the colour of the marker. ...