第五章 子图的绘制及坐标轴共享

第五章 子图的绘制及坐标轴共享

1.绘制固定区域的子图

​ matplotlib可以将整个画布规划成等分布局的mn(行列)的矩阵区域,并按照先行后列的方式对每个区域进行编号(编号从1开始),之后在选中的某个或某些区域中绘制单个或多个子图。

image-20231020103944496

1.1.绘制单子图

​ 使用pyplot模块的subplot()函数可以在规划好的某个区域中绘制单个子图。其语法结构为:

subplot(nrows, ncols, index, projection, polar, sharex, sharey, 
label, **kwargs)
  • nrows:表示规划区域的行数。
  • ncols:表示规划区域的列数。
  • index:表示选择区域的索引,默认从1开始编号。
  • projection:表示子图的投影类型。
  • polar:表示是否使用极坐标,默认值为False。若参数polar设为True,则作用等同于projection=‘polar’。

​ 参数nrowsncolsindex既支持单独传参,也支持以一个3位整数(每位整数必须小于10)的形式传参。
subplot()函数会返回一个 Axes类的子类SubplotBase的对象。
​ Figure类对象可以使用add_subplot()方法绘制单子图,此方式与subplot()函数的作用是等价的。

import matplotlib.pyplot as plt

# 画布被规划为3x2的矩阵区域,之后在索引为6的区域中绘制子图
ax_one = plt.subplot(326)
ax_one.plot([1, 2, 3, 4, 5])
# 画布被绘画为3x1的矩阵区域,之后在索引为2的区域中绘制子图
ax_two = plt.subplot(312)
ax_two.plot([1, 2, 3, 4, 5])
plt.show()

运行结果:

image-20231020105139549

1.2.实例:某工厂产品A与产品B去年的销售额分析

​ 本实例要求根据下表的数据,先将画布规划成2*1的矩阵区域,并在索引为1的区域中绘制反映产品A和产品B销售额趋势的折线图;再将画布规划成2*2的矩阵区域,并在索引为3的区域中绘制反映产品A销售额占比的饼图;最后将画布规划成2*2的矩阵区域,并在索引为4的区域中绘制反映产品B销售额占比的饼图

image-20231020105520992 image-20231020105529682 image-20231020105543996
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

x = [x for x in range(1, 13)]
y1 = [20, 28, 23, 16, 29, 36, 39, 33, 31, 19, 21, 25]
y2 = [17, 22, 39, 26, 35, 23, 25, 27, 29, 38, 28, 20]
labels = ['1月', '2月', '3月', '4月', '5月', '6月', '7月',
          '8月', '9月', '10月', '11月', '12月']

# 将画布规划成等分布局的2x1的矩阵区域,之后在索引为1的区域中绘制子图
ax1 = plt.subplot(211)
ax1.plot(x, y1, 'm--o', lw=2, ms=5, label='产品A')
ax1.plot(x, y2, 'g--o', lw=2, ms=5, label='产品B')
ax1.set_title('产品A与产品B的销售额趋势', fontsize=11)
ax1.set_ylim(10, 45)  # y轴区间
ax1.set_ylabel('销售额(亿元)')
ax1.set_xlabel('月份')
for xy1 in zip(x, y1):
    ax1.annotate("%s" % xy1[1], xy=xy1, xytext=(-5, 5), textcoords='offset points')
for xy2 in zip(x, y2):
    ax1.annotate("%s" % xy2[1], xy=xy2, xytext=(-5, 5), textcoords='offset points')
ax1.legend()
# 将画布规划成等分布局的2x2的矩阵区域,之后在索引为3的区域中绘制子图
ax2 = plt.subplot(223)
ax2.pie(y1, radius=1, wedgeprops={'width': 0.5}, labels=labels,
        autopct='%3.1f%%', pctdistance=0.75)
ax2.set_title('产品A的销售额')
# 将画布规划成等分布局的2x2的矩阵区域,之后在索引为4的区域中绘制子图
ax3 = plt.subplot(224)
ax3.pie(y2, radius=1, wedgeprops={'width': 0.5}, labels=labels,
        autopct='%3.1f%%', pctdistance=0.75)
ax3.set_title('产品B的销售额')
# 调整子图之间的距离
plt.tight_layout()
plt.show()
image-20231020112043034

1.3.绘制多子图

​ 使用pyplot模块的subplots()函数可以在规划好的所有区域中一次绘制多个子图。

subplots(nrows=1,ncols=1,sharex=False,sharey=False,squeeze=True,subplot_kw=None,gridspec_kw=None**fig_kw)
  • nrows:表示规划区域的行数,默认为1。
  • ncols:表示规划区域的列数,默认为1。
  • sharex, sharey:表示是否共享子图的x轴或y轴。

subplots()函数会返回包含两个元素的元组,其中该元组的第一个元素为Figure对象,第二个元素为Axes对象或Axes对象数组。

import matplotlib.pyplot as plt

# 将画布划分为2x2的等分区域
fig, ax_arr = plt.subplots(2, 2)
# 获取sx_arr数组第1行第0列的元素,也就是第3个区域
ax_thr = ax_arr[1, 0]
ax_thr.plot([1, 2, 3, 4, 5])
plt.show()
image-20231020113321404

1.4.实例:部分国家养猫与养狗人群比例分析

​ 随着人们生活水平的提高,许多人都会在家里养一些萌宠,有时还会在抖音上分享萌宠日常的可爱视频。

​ 本实例要求根据下表的数据,将整个画布规划成1*2的矩阵区域,并在索引为1和索引为2的区域中分别绘制反映养猫人群比例与养狗人群比例的条形图

image-20231026103157433 image-20231026103203217 image-20231026103350018
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

# 添加无指向型注释文本
def autolabel(ax, rects):
    """ 在每个矩形条上方附加一个文本标签,以显示其高度"""
    for rect in rects:
        width = rect.get_width()  # 获取每个矩形条的高度
        ax.text(width + 3, rect.get_y(), s='{}'.format(width),
                ha='center', va='bottom')
y = np.arange(12)
x1 = np.array([19, 33, 28, 29, 14, 24, 57, 6, 26, 15, 27, 39])
x2 = np.array([25, 33, 58, 39, 15, 64, 29, 23, 22, 11, 27, 50])

labels = np.array(['中国', '加拿大', '巴西', '澳大利亚', '日本', '墨西哥',
                   '俄罗斯', '韩国', '瑞士', '土耳其', '英国', '美国'])

# 将画布规划为1x2的矩阵区域,依次在每个区域中绘制子图
fig, (ax1, ax2) = plt.subplots(1, 2)
barh_rects = ax1.barh(y, x1, height=0.5, tick_label=labels, color='#FFA500')
ax1.set_xlabel('人群比例(%)')
ax1.set_title('部分国家养猫人群的比例')
ax1.set_xlim(0, x1.max() + 10)
autolabel(ax1, barh_rects)
barh2_rects = ax2.barh(y, x2, height=0.5, tick_label=labels, color='#10B2AA')
ax1.set_xlabel('人群比例(%)')
ax1.set_title('部分国家养猫人群的比例')
ax2.set_xlim(0, x2.max() + 10)
autolabel(ax2, barh2_rects)

# 调整他子图之间的距离
plt.tight_layout()
plt.show()

2.绘制自定义区域的子图

2.1.绘制自定义区域子图

​ 使用pyplot模块的subplot2grid()函数可以将整个画布规划成非等分布局的区域,并可在选中的某个区域中绘制单个子图。 语法格式如下:

ubplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs)
  • shape:表示规划的区域结构,该参数接收一个包含两个整型数据的元组,元组中第1个元素表示规划区域的行数,第2个元素代表规划区域的列数。
  • loc:表示选择区域的位置,该参数接收一个包含两个整型数据的元组,元组中第1个元素表示子图所在的行数(行数从0开始),第2个元素表示子图所在的列数(列数从0开始)。
  • rowspan:表示向下跨越的行数,默认为1。
  • colspan:表示向右跨越的列数,默认为1。
import matplotlib.pyplot as plt

# 将画布规划成2x3的矩阵区域,之后在第0行第2列的区域中绘制子图
ax1 = plt.subplot2grid((2, 3), (0, 2))
ax1.plot([1, 2, 3, 4, 5])
# 画布被规划成2x3的矩阵区域,之后在第一行第1-2列的区域中绘制子图
ax2 = plt.subplot2grid((2, 3), (1, 1), colspan=2)
ax2.plot([1, 2, 3, 4, 5])
plt.show()
image-20231026110328723

2.2.实例:2017年与2018年抖音用户分析

​ 抖音是一款音乐创意短视频社交软件,该软件自2016年9月上线以来受到越来越多年轻人的欢迎。用户可以通过这款软件选择歌曲,拍摄音乐短视频,生成自己的作品。

​ 本实例要求根据下表的数据,使用3个子图进行展示:在第01行第01列的区域中,绘制说明2018年相比于2017年人群增长倍数的柱形图;在第2行第0列、第2行第1列的区域中,分别绘制说明2017年、2018年抖音用户地区分布比例的饼图

image-20231026110544185 image-20231026110548742 image-20231026110606161
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

data_2017 = np.array([21, 35, 22, 19, 3])
data_2018 = np.array([13, 32, 27, 27, 1])
x = np.arange(5)
y = np.array([51, 73, 99, 132, 45])
labels = np.array(['一线城市', '二线城市', '三线城市', '四线及以外', '其他国家及地区'])

# 平均增长倍数
average = 75
bar_width = 0.5
# 添加无指向型注释文本
def autolabel(ax, rects):
    """ 在每个举行条的上方附加一个文本标签,以显示其高度"""
    for rect in rects:
        height = rect.get_height()  # 获取每个矩形条的高度
        ax.text(rect.get_x() + bar_width / 2, height + 3,
                s='{}'.format(height), ha='center', va='bottom')

# 第一个子图
ax_one = plt.subplot2grid((3, 2), (0, 0), rowspan=2, colspan=2)
bar_rects = ax_one.bar(x, y, tick_label=labels, color='#20B2AA',
                       width=bar_width)
ax_one.set_title('抖音2018vs2017人群增长倍数')
ax_one.set_ylabel('增长倍数')
ax_one.set_ylim(0, y.max() + 20)
ax_one.axhline(y=75, ls='--', lw=1, color='gray')

# 第二个子图
ax_two = plt.subplot2grid((3, 2), (2, 0))
ax_two.pie(data_2017, radius=1.5, labels=labels, autopct='%3.1f%%',
           colors=['#2F4F4F', '#FF0000', '#A9A9A9', '#FFD700', '#B0C4DE'])
ax_two.set_title('2017年抖音用户地区分布的比例')

# 第三个子图
ax_thr = plt.subplot2grid((3, 2), (2, 1))
ax_thr.pie(data_2018, radius=1.5, labels=labels, autopct='%3.1f%%',
           colors=['#2F4F4F', '#FF0000', '#A9A9A9', '#FFD700', '#B0C4DE'])
ax_thr.set_title('2018年抖音用户地区分布的比例')

# 调整子图之间的距离
plt.tight_layout()
plt.show()

3.共享子图坐标轴

3.2.共享相邻子图的坐标轴

​ 当使用subplots()函数绘制子图时,可以通过该函数的sharexsharey参数控制是否共享x轴或y轴sharexsharey参数支持False或’none’、True或’all’、‘row’、‘col’中任一取值。

  • True或'all':表示所有子图之间共享x轴或y轴。
  • False或'none':表示所有子图之间不共享x轴或y轴。
  • 'row':表示每一行的子图之间共享x轴或y轴。
  • 'col':表示每一列的子图之间共享x轴或y轴。
image-20231026114026919
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
x1 = np.linspace(0, 2*np.pi, 400)
x2 = np.linspace(0.01, 10, 100)
x3 = np.random.rand(10)
x4 = np.arange(0, 6, 0.5)
y1 = np.cos(x1**2)
y2 = np.sin(x2)
y3 = np.linspace(0, 3, 10)
y4 = np.power(x4, 3)

# 共享每一列子图之间的x轴
fig, ax_arr = plt.subplots(2, 2, sharex='col')
ax1 = ax_arr[0, 0]
ax1.plot(x1, y1)
ax2 = ax_arr[0, 1]
ax2.plot(x2, y2)
ax3 = ax_arr[1, 0]
ax3.scatter(x3, y3)
ax4 = ax_arr[1, 1]
ax4.scatter(x4, y4)
plt.show()
image-20231026123158700

3.2.共享非相邻子图的坐标轴

​ 当使用pyplot的subplot()函数绘制子图时,也可以将代表其它子图的变量赋值给该函数的sharexsharey参数,此时可以共享非相邻子图之间的坐标轴。

import numpy as np
import matplotlib.pyplot as plt
x1 = np.linspace(0, 2*np.pi, 400)
y1 = np.cos(x1**2)
x2 = np.linspace(0.01, 10, 100)
y2 = np.sin(x2)
ax_one = plt.subplot(221)
ax_one.plot(x1, y1)
# 共享子图ax_one和ax_two的x轴
ax_two = plt.subplot(224, sharex=ax_one)
ax_two.plot(x2, y2)

plt.show()
image-20231031164946590

3.3.实例:某地区全年气温和水量的关系

​ 气候是地球上某一地区大气的多年平均状况,主要有光照、气温、降水等气候要素,其中气温、降水是反映一个地区气候特征的重要指标。

​ 本实例要求根据下表的数据,将月份列的数据作为x轴的刻度标签,将平均气温、降水量、蒸发量三列的数据作为y轴的数据,在同一绘图区域中分别绘制反映平均气温、降水量、蒸发量关系的图表

image-20231031165115676

image-20231031165122987image-20231031165133693

image-20231031165122987image-20231031165133693

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

month_x = np.arange(1, 13, 1)
# 平均气温
data_temp = np.array([2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3,
                     33.4, 23.0, 16.5, 12.0, 6.2])
# 降水量
data_precipitation = np.array([2.6, 5.9, 9.0, 26.4, 28.7, 70.7,
                               175.6, 182.2, 48.7, 18.8, 6.0, 2.3])
# 蒸发量
data_evaporation = np.array([2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6,
                             182.2, 48.7, 18.8, 6.0, 2.3])

labels = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月'
          , '9月', '10月', '11月', '12月']
fig, ax = plt.subplots()
bar_ev = ax.bar(month_x, data_evaporation, color='orange',
                tick_label=labels)
bar_pre = ax.bar(month_x, data_precipitation, bottom=data_evaporation,
                 color='green')
ax.set_ylabel('水量(ml)')
ax.set_title('平均气温和降水量、蒸发量的关系')
ax_right = ax.twinx()  # 该方法共享同一子图的坐标轴
line = ax_right.plot(month_x, data_temp, 'o-m')
ax_right.set_ylabel('气温($\circ$C)')
# 添加图例
plt.legend([bar_ev, bar_pre, line[0]], ['蒸发量', '降水量', '平均气温'],
           shadow=True, fancybox=True)
plt.show()
image-20231031170516295

4.子图的布局

​ 当带有标题的多个子图并排显示时,多个子图会因区域过于紧凑而出现标题和坐标轴之间相互重叠的问题,而且子图元素的摆放过于紧凑,影响用户的正常查看。matplotlib中提供了一些调整子图布局的方法,包括约束布局、紧密布局和自定义布局,通过这些方法可以合理布局多个子图。

4.1.约束布局

​ 约束布局是指通过一系列限制来确定画布中元素的位置的方式,它预先会确定一个元素的绝对定位,之后以该元素的为基点将其它元素进行绝对定位,从而灵活地定位和调整元素的位置。

​ matplotlib在绘制多子图时默认并未启用约束布局,它提供了两种方式启用约束布局:第一种方式是使用subplots()figure()函数的constrained_layout参数,第二种方式是修改figure.constrained_layout.use配置项。

  • **第一种:**在使用subplots()figure()函数创建子图或画布时,可以将这些函数的constrained_ layout参数的值设置为True,以启用约束布局来调整图表元素的位置。
plt.subplots(constrained_layout=True)
  • 第二种:matplotlib可以通过rcParams字典或rc()函数修改figure.constrained_layout.use配置项的值为True,以启用约束布局来调整图表元素的位置。
plt.rcParams['figure.constrained_layout.use'] = True

​ 除此之外,通过以下配置项或者是Figure类对象的方法可以使用约束布局或者手动调整子图的内边距。

  • figure.constrained_layout.w_pad/ h_pad:表示绘图区域的内边距。
  • figure.constrained_layout.wspace/ hspace:表示子图之间的间隙,默认为 0.02。
  • set_constrained_layout():设置是否使用约束布局。若该方法传入参数None,则说明使用配置文件中rcParams['figure.constrained_layout.use']指定的值。
  • set_constrained_layout_pads():设置子图的内边距。

​ 约束布局仅适用于调整刻度标签、轴标签、标题和图例的位置,而不会调整子图其他元素的位置。因此,使用约束布局后的子图之间仍然会出现图表元素被裁剪或重叠的问题。

import numpy as np
import matplotlib.pyplot as plt

fig, axs = plt.subplots(2, 2, constrained_layout=True)
ax_one = axs[0, 0]
ax_one.set_title('Title')
ax_two = axs[0, 1]
ax_one.set_title('Title')
ax_thr = axs[1, 0]
ax_thr.set_title('Title')
ax_fou = axs[1, 1]
ax_fou.set_title('Title')
plt.show()
image-20231031171515450

4.2.紧密布局

​ 紧密布局采用紧凑的形式将子图排列到画布中,仅适用于刻度标签、坐标轴标签和标题位置的调整。
pyplot中提供了两种实现紧密布局的方式。

  • 第一种:使用tight_layout()函数。

​ matplotlib在1.1版本中引入了tight_layout()函数,通过该函数可以调整子图的内边距及子图的间隙,使子图能适应画布的绘图区域。

tight_layout(pad=1.08, h_pad=None, w_pad=None, rect=None) 

pad:表示画布边缘与子图边缘之间的空白区域的大小,默认为1.08。
h_pad,w_pad:表示相邻子图之间的空白区域的大小。
rect:表示调整所有子图位置的矩形区域的四元组(left, bottom, right, top),默认为 (0,0,1,1)。

​ 当pad参数设为0时,空白区域的文本会出现被裁剪的现象,之所以产生文本部分缺失的情况,可能是因为算法错误或受到算法的限制。因此,官方建议pad参数的取值应至少大于0.3。

  • 第二种:修改figure.autolayoutrcParam 配置项。

​ pyplot可以通过rcParams字典或rc()函数修改figure.autolayoutrcParam配置项的值为True,使子图元素能适应画布的绘图区域。

plt.rcParams['figure.autolayoutrcParam'] = True
import numpy as np
import matplotlib.pyplot as plt

fig, axs = plt.subplots(2, 2)
ax_one = axs[0, 0]
ax_one.set_title('Title')
ax_two = axs[0, 1]
ax_one.set_title('Title')
ax_thr = axs[1, 0]
ax_thr.set_title('Title')
ax_fou = axs[1, 1]
ax_fou.set_title('Title')
# 调整子图之间的间距
plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=2)
plt.show()
image-20231031172035554

4.3.自定义布局

​ matplotlib的gridspec模块是专门指定画布中子图位置的模块,该模块中包含一个GridSpec类,通过显式地创建GridSpec类对象来自定义画布中子图的布局结构,使得子图能够更好地适应画布。

GridSpec(nrows, ncols, figure=None, left=None, bottom=None, right=None, top=None, wspace=None, hspace=None, width_ratios=None, height_ratios=None)
  • nrows:表示行数。
  • ncols:表示列数。
  • figure:表示布局的画布。
  • left,bottom,right,top:表示子图的范围。
  • wspace:表示子图之间预留的宽度量。
  • hspace:表示子图之间预留的高度量。
import matplotlib.gridspec as gredspec
import matplotlib.pyplot as plt

fig2 = plt.figure()
spec2 = gredspec.GridSpec(ncols=2, nrows=2, figure=fig2)
f2_ax1 = fig2.add_subplot(spec2[0, 0])
f2_ax2 = fig2.add_subplot(spec2[0, 1])
f2_ax3 = fig2.add_subplot(spec2[1, 0])
f2_ax4 = fig2.add_subplot(spec2[1, 1])
plt.show()
image-20231031173940055

​ matplotlib中还为Figure对象提供了快速添加布局结构的方法add_gridspec()

import matplotlib.gridspec as gredspec
import matplotlib.pyplot as plt

fig3 = plt.figure()
gs =fig3.add_gridspec(3, 3)
f3_ax1 = fig3.add_subplot(gs[0, :])
f3_ax2 = fig3.add_subplot(gs[0, :-1])
f3_ax3 = fig3.add_subplot(gs[1:, -1])
f3_ax4 = fig3.add_subplot(gs[-1, 0])
f3_ax5 = fig3.add_subplot(gs[-1, -1])
plt.show()
image-20231031174315554

4.4.实例:2018上半年某品牌汽车销售情况

​ 随着人们的生活水平日益提高,汽车已经成为人们出行的代步工具,为人们的生活带来了便利。已知某品牌汽车在北京、上海、广州、深圳、浙江、山东设立了6个分公司,各分公司在2018年的销售额十分可观。

​ 本实例要求根据下表的数据,分别使用3个子图进行展示:在第0行第0列的区域中,绘制反映2018上半年汽车销售额的柱形图;在第1行第0列和第1行第1列的区域中,绘制反映2018上半年各分公司汽车销量的折线图和堆积面积图。

image-20231031174421026

image-20231031174432321
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False


x_month = np.array(['1月', '2月', '3月', '4月', '5月', '6月'])
y_sales = np.array([2150, 1050, 1560, 1480, 1530, 1490])
x_citys = np.array(['北京', '上海', '广州', '深圳', '浙江', '山东'])
y_sale_count = np.array([83775, 62860, 59176, 64205, 48671, 39968])
# 创建画布和布局
fig = plt.figure(constrained_layout=True)
gs = fig.add_gridspec(2, 2)
ax_one = fig.add_subplot(gs[0, 1])
ax_two = fig.add_subplot(gs[1, 0])
ax_thr = fig.add_subplot(gs[1, 1])
# 第一个子图
ax_one.bar(x_month, y_sales, width=0.5, color='#3299CC')
ax_one.set_title('2018年上半年某品牌汽车的销售额')
ax_one.set_ylabel('销售额(亿元)')
# 第二个子图
ax_two.plot(x_citys, y_sale_count, 'm--o', ms=8)
ax_two.set_title('分公司某品牌汽车的销量')
ax_two.set_ylabel('销量(辆)')
# 第三个子图
ax_thr.stackplot(x_citys, y_sale_count, color='#9999FF')
ax_thr.set_title('分公司某品牌汽车的销量')
ax_thr.set_ylabel('销量(辆)')
plt.show()

= plt.figure(constrained_layout=True)
gs = fig.add_gridspec(2, 2)
ax_one = fig.add_subplot(gs[0, 1])
ax_two = fig.add_subplot(gs[1, 0])
ax_thr = fig.add_subplot(gs[1, 1])

第一个子图

ax_one.bar(x_month, y_sales, width=0.5, color=‘#3299CC’)
ax_one.set_title(‘2018年上半年某品牌汽车的销售额’)
ax_one.set_ylabel(‘销售额(亿元)’)

第二个子图

ax_two.plot(x_citys, y_sale_count, ‘m–o’, ms=8)
ax_two.set_title(‘分公司某品牌汽车的销量’)
ax_two.set_ylabel(‘销量(辆)’)

第三个子图

ax_thr.stackplot(x_citys, y_sale_count, color=‘#9999FF’)
ax_thr.set_title(‘分公司某品牌汽车的销量’)
ax_thr.set_ylabel(‘销量(辆)’)
plt.show()


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值