首页 技术 正文
技术 2022年11月15日
0 收藏 481 点赞 3,404 浏览 2315 个字

控制颜色

Python3绘图库Matplotlib(02)

Color Color Name
b blue
c cyan
g green
k black
m magenta
r red
w white
y yellow

plt.plot(x1, y1, fmt1, x2, y2, fmt2, …)

控制线的风格

Python3绘图库Matplotlib(02)

Style Style
solid line
dashed line
-. dash-dot line
: dotted line

控制标记样式

Python3绘图库Matplotlib(02)

. 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

Python3绘图库Matplotlib(02)

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

Python3绘图库Matplotlib(02)

处理X和Y的ticks标签值

Python3绘图库Matplotlib(02)

画图的类型

Python3绘图库Matplotlib(02)

直方图图表 = Histogram charts

Python3绘图库Matplotlib(02) 

Error bar charts

Python3绘图库Matplotlib(02)Python3绘图库Matplotlib(02)

Bar Charts

Python3绘图库Matplotlib(02)Python3绘图库Matplotlib(02)

本小结代码示例

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,

有幸看到我博客的朋友们,若能学到知识,请多多关注以及讨论,让我们共同进步,扬帆起航。

后记:打油诗一首

适度锻炼,量化指标

考量天气,设定目标

科学锻炼,成就体标

高效科研,实现学标


    

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,565
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905