Python学习笔记

Matplotlib

  • 可用形状

‘s’ : 方块状
‘o’ : 实心圆
‘^’ : 正三角形
‘v’ : 反正三角形
‘+’ : 加好
‘*’ : 星号
‘x’ : x号
‘p’ : 五角星
‘1’ : 三脚架标记
‘2’ : 三脚架标记

  • 实例
  • 设置图表属性
    plt.figure(figsize=(15,10),dpi=100)
    plt.title(‘GDP_cn’,fontsize=15) # 设置图表标题
    plt.xlabel(‘stats_year’,fontsize=10) # 设置x轴标题
    plt.ylabel(‘gross_product’,fontsize=10) # 设置y轴标题
    plt.xticks(df[‘stats_year’].astype(int)) # x轴的刻度
    plt.ylim(30000,1000000) # y轴坐标范围
    plt.yticks(np.linspace(100000,1000000,19)) # 设置x轴刻度的显示步长
  • 显示数据
    plt.plot(df[‘stats_year’],df[‘GDP’],color=“goldenrod”,linewidth=2,label=‘GDP’,marker=’’) # GDP by years
    #color:颜色,linewidth:线宽,linestyle:线条类型,label:图例,marker:数据点的类型
    plt.plot(df[‘stats_year’],df[‘first_industry’],color=“purple”,linewidth=1,label=‘first_industry’,marker=’
    ’) # first_industry by years
    plt.plot(df[‘stats_year’],df[‘second_industry’],color=“dodgerblue”,linewidth=1,label=‘second_industry’,marker=’’) # second_industry by years
    plt.plot(df[‘stats_year’],df[‘tertiary_industry’],color=“red”,linewidth=1,label=‘tertiary_industry’,marker=’
    ’) # tertiary_industry by years
    plt.legend(loc=2) # 图例展示位置,数字代表第几象限
    在这里插入图片描述
  • 参考链接

https://www.cnblogs.com/qianblue/p/10783261.html # 颜色选择
https://blog.csdn.net/qq_37107304/article/details/96482645 # 双轴显示,栅格

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值