# 创建图表和第一个纵坐标轴 fig, ax1 = plt.subplots() # 绘制销售额数据 color = 'tab:red' ax1.set_xlabel('月份') ax1.set_ylabel('销售额 (万元)', color=color) ax1.plot(months, sales, color=color, marker='o', label='销售额') ax1.tick_pa
ax1 = plt.subplot(gs[0, 0]) ax2 = plt.subplot(gs[0, 1]) # 子图1 ax1.plot(heights.index, heights.values) ax1.set_title('运动员身高频数分布折线图') ax1.set_xlabel('身高(cm)') ax1.set_ylabel('人数') # 子图2 ax2.plot(weights.index, weights.values) ax2.set_title('运动员...
ax1.set_xlabel('x轴', fontdict={'size': 16}) ax1.set_ylabel('y1轴',fontdict={'size': 16}) ax2.set_ylabel('y2轴',fontdict={'size': 16}) #添加图表题 plt.title('双y轴折线图') #添加图例 plt.legend() # 设置中文显示 plt.rcParams['font.sans-serif']=['SimHei'] #展示图片 ...
set_xlabel('Checking Account') axs[1].set_ylabel('Count') plt.tight_layout() plt.show() 输出结果: 贷款情况对比 fig = plt.figure(figsize=(17,15)) # 创建2x2的图布局 ax1 = fig.add_subplot(2, 2, 1) ax2 = fig.add_subplot(2, 2, 2) ax3 = fig.add_subplot(2, 1, 2) sns....
sns.heatmap(pt, linewidths = 0.05, ax = ax1, vmax=900, vmin=0, cmap=cmap) ax1.set_title('cubehelix map') ax1.set_xlabel('') ax1.set_xticklabels([]) #设置x轴图例为空值 ax1.set_ylabel('kind') # cmap用matplotlib colormap ...
ax1.set_xlabel("Sulphates") ax1.set_ylabel("Frequency") sns.kdeplot(wines['sulphates'], ax=ax1, shade=True, color='steelblue') 可视化 1 维连续型数值数据 从上面的图表中可以看出,葡萄酒中硫酸盐的分布存在明显的右偏(right skew)。
#设置x轴的位置x =df.index#创建画布和子图fig, ax1 = plt.subplots() 绘制柱状图和折线图 接下来,我们将绘制柱状图和折线图,并添加相应的数据标签和图例。 #绘制柱状图ax1.bar(x, df['销售数量'], label='销售数量', color='skyblue', width=0.4)#添加数据标签fori, vinenumerate(df['销售数量']):...
ax1 = plt.subplot(gs[0, 0]) ax2 = plt.subplot(gs[0, 1]) ax3 = plt.subplot(gs[1, 0]) ax4 = plt.subplot(gs[1, 1]) ax1.barh(skill[::-1], counts[::-1], height=0.5, color='#FF00FF') ax1.set_xlabel('人数') ...
cys.append(cy)# Plottingfig, ax1 = plt.subplots(figsize=(10,6)) color ='tab:red'ax1.set_xlabel('Date') ax1.set_ylabel('Close', color=color) ax1.plot(dates, closes, color=color, label='Close') ax1.tick_params(axis='y', labelcolor=color) ...
ax1.set_xlabel("X-axis")ax1.set_ylabel("Y-axis 1")ax2.set_ylabel("Y-axis 2")ax1.legend(loc=2)ax2.legend(loc=1) 1. 2. 3. 4. 5. 在这个步骤中,我们使用set_xlabel()和set_ylabel()函数设置X轴和Y轴的标签。然后,我们使用legend()函数创建图例...