第五章Matplotlib Charts
Creating beautiful charts using Matplotlib
Matplotlib – downloading modules using pip
Matplotlib – downloading modules with whl extensions
Creating our first chart
Placing labels on charts
How to give the chart a legend
Scaling charts
Adjusting the scale of charts dynamically
第一节:Creating beautiful charts using Matplotlib
绘制了一个3D图形
Matplotlib网站:
https://matplotlib.org/users/screenshots.html
第二节:Matplotlib – downloading modules using pip
第三节:Matplotlib – downloading modules with whl extensions
这两节主要讲怎么安装matplotlib
第四节:Creating our first chart
python中numpy的arange不是安排什么,而是创建了一个序列
第五节:Placing labels on charts
我们import了matplotlib模块创建了一个canvas和一个figure来画图
设置x和y的坐标值和一些关于图表的参数
第六节:How to give the chart a legend
添加图例
fig.legend((t0,t1,t2),('pie','cherry pie','RR'),'upper right')
添加图例,传入的是元组
第一个参数是变量的元组,第二个参数是每条线的命名的元组,第三个参数是图例的位置在右上方
第七节:Scaling charts
axis.set_ylim(5,8)
设置了y轴的取值范围
第八节:Adjusting the scale of charts dynamically
把x轴的取值也设置在(0,8)之间
但这个图看起来还是非常怪异
我们将y轴的取值范围设置在y0,y1和y2中的最小值和最大值之间
x轴的取值范围设置在x的最小值和最大值之间
领取专属 10元无门槛券
私享最新 技术干货