20190706——matplotlib——折线图

多个坐标系显示plt.subplots(面向对象的画图方法)

在这里插入图片描述
在这里插入图片描述
会返回两个对象,那么如何对单独的对象进行操作?
axes[0]
axes[1]
.方法名调用

在这里插入图片描述

x = range(60)
y_shanghai = [random.uniform(15,18) for i in x]
y_beijing = [random.uniform(1,3) for i in x]
figure , axes = plt.subplots(nrows=1, ncols=2, figsize=(20,8),dpi=80)
axes[0].plot(x,y_shanghai, color="r", linestyle="--", label="上海")
axes[1].plot(x,y_beijing, color="b",label="北京")
axes[0].legend()
axes[1].legend()
x_label = ["11点{}分".format(i) for i in x]
axes[0].set_xticks(x[::5], x_label[::5])
axes[0].set_yticks(range(0,40,5))
axes[1].set_xticks(x[::5], x_label[::5])
axes[1].set_yticks(range(0,40,5))
axes[0].grid(True, linestyle="--", alpha =0.5)
axes[1].grid(True, linestyle="--", alpha =0.5)
axes[0].set_xlabel("时间")
axes[0].set_ylabel("温度")
axes[0].set_title("上海11点0分到12点之间的温度变化表示")
axes[1].set_xlabel("时间")
axes[1].set_ylabel("温度")
axes[1].set_title("北京11点0分到12点之间的温度变化表示")
plt.show()

折线图的应用场景
呈现公司产品(不同区域)每天活跃用户数
呈现app每天下载数量
呈现产品功能上线后,用户点击次数随时间的变化

绘制数学函数图像
在这里插入图片描述
在这里插入图片描述

  • 11
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值