Python3绘图库Matplotlib(02)
2018-07-03 01:11:37来源:博客园 阅读 ()

控制颜色

Color | Color Name |
b | blue |
c | cyan |
g | green |
k | black |
m | magenta |
r | red |
w | white |
y | yellow |
控制线的风格

Style | Style |
- | solid line |
-- | dashed line |
-. | dash-dot line |
: | dotted line |
控制标记样式

. | Point marker |
, | Pixel marker |
o | Circle marker |
v | Triangle down |
^ | Triangle up marker |
< | Triangle left marker |
> | Triangle right marker |
1 | Tripod down marker |
2 | Tripod up marker |
3 | Tripod left marker |
4 | Tripod right marker |
s | Square marker |
p | Pentagon marker |
* | Star marker |
h | Hexagon marker |
H | Rotated hexagon marker |
+ | Plus marker |
x | Cross marker |
D | Diamond marker |
d | Thin diamond marker |
| | Vertical line |
_ | Horizontal line |

用关键字参数进行更好的控制

处理X和Y的ticks标签值

画图的类型

直方图图表 = Histogram charts

Error bar charts


Bar Charts


本小结代码示例
import matplotlib.pyplot as plt import numpy as np y = np.arange(1, 3) plt.plot(y, 'y') plt.plot(y+1, 'm') plt.plot(y+2, 'c') plt.show() import matplotlib.pyplot as plt import numpy as np y = np.arange(1, 3) plt.plot(y, '--', y+1, '-.', y+2, ':') plt.show() import matplotlib.pyplot as plt import numpy as np y = np.arange(1, 3, 0.2) plt.plot(y, 'x', y+0.5, 'o', y+1, 'D', y+1.5, '^', y+2, 's') plt.show() import matplotlib.pyplot as plt import numpy as np y = np.arange(1, 3, 0.3) plt.plot(y, 'cx--', y+1, 'mo:', y+2, 'kp-.') plt.show() import matplotlib.pyplot as plt import numpy as np y = np.arange(1, 3, 0.3) plt.plot(y, color='blue', linestyle='dashdot', linewidth=4, marker='o', markerfacecolor='red', markeredgecolor='black', markeredgewidth=3, markersize=12) plt.show() import matplotlib.pyplot as plt x = [5, 3, 7, 2, 4, 1] plt.plot(x) plt.xticks(range(len(x)), ['a', 'b', 'c', 'd', 'e', 'f']) plt.yticks(range(1, 8, 2)) plt.show() import matplotlib.pyplot as plt import numpy as np y = np.random.randn(1000) plt.hist(y) plt.show() plt.hist(y, 25) plt.show() import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 4, 0.2) y = np.exp(-x) e1 = 0.1 * np.abs(np.random.randn(len(y))) plt.errorbar(x, y, yerr=e1, fmt='.-') plt.show() e2 = 0.1 * np.abs(np.random.randn(len(y))) plt.errorbar(x, y, yerr=e1, xerr=e2, fmt='.-', capsize=0) plt.show() plt.errorbar(x, y, yerr=[e1, e2], fmt='.-') plt.show() import matplotlib.pyplot as plt plt.bar([1, 2, 3], [3, 2, 5]) plt.show() import matplotlib.pyplot as plt import numpy as np data1 = 10*np.random.rand(5) data2 = 10*np.random.rand(5) data3 = 10*np.random.rand(5) e2 = 0.5*np.abs(np.random.randn(len(data2))) locs = np.arange(1, len(data1)+1) width = 0.27 plt.bar(locs+width, data2, yerr=e2, width=width, color='red') plt.bar(locs+2*width, data3, width=width, color='green') plt.show()
知识在于点点滴滴的积累,我会在这个路上Go ahead,
后记:打油诗一首
适度锻炼,量化指标
考量天气,设定目标
科学锻炼,成就体标
高效科研,实现学标
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- python3基础之“术语表(2)” 2019-08-13
- python3 之 字符串编码小结(Unicode、utf-8、gbk、gb2312等 2019-08-13
- Python3安装impala 2019-08-13
- python3 enum模块的应用 2019-08-13
- python3 之 趣味数学题(爱因斯坦) 2019-08-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash