matplotlib绘图--完整-基础教程(一)

matplotlib的安装在之前的博客里有提到,可以去找找看


折线图





在同一张图中显示多个线条是因为hold属性是默认打开的,将属性关闭那么新的绘制将把之前的线条覆盖。

interactive是打开交互模式,随时可以观测线条的变化。


Adding a grid

1

2


Handling axes

默认坐标轴自适应,可以限制显示方式。

3

4

还有这几种方式控制坐标轴的变化:

  • plt.axis([xmin, xmax, ymin, ymax])
  • plt.axis(xmin=NNN, ymax=NNN)

Adding labels

5


Adding a title

6


Adding a legend

7

可以通过参数loc修改图标位置,0-10表示不一样的位置。还可以通过,loc=(0,1)表示左上角,(0.5,0.5)表示中间。当然,也可以利用loc='best'自适应。


A complete example

8

9


Saving plots to a file

10

11

12


Configuring through the Python code

13

14


Selecting backend from code

15


Control colors


1

2

3

4


Specifying styles in multiline plots

5


Control line styles

6

7


Control marker styles


8

9

10

11


Finer control with keyword arguments

12

13


Handling X and Y ticks

14


Plot types

15


Histogram charts

16

17

18

By default, hist() uses a bin value of 10 (so only ten categories, or bars, are computed), but we can customize it, either by passing an additional parameter, for example, in hist(y, <bins>), or using the bin keyword argument as hist(y, bin=<bins>).


19

Error bar charts

20


Bar charts

21

22

23

24

25

26


Pie charts

27

28

29


Scatter plots (散点图)

1

2


Polar charts

Control radial and angular grids


Text inside figure, annotations, and arrows

Text inside figure

Annotations

Arrows

Advanced Matplotlib

三种风格的显示图表



A brief introduction to Matplotlib objects

Our first (simple) example of OO Matplotlib

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值