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 # 双轴显示,栅格