#scatter
fig=plt.figure()
ax=fig.add_subplot(3,3,1)#3行3列 第一个图
n=128
X=np.random.normal(0,1,n)
Y=np.random.normal(0,1,n)
T=np.arctan2(Y,X)#T用来上色的
#plt.axes([0.025,0.025,0.95,0.95])#显示的范围
ax.scatter(X,Y,s=75,c=T,alpha=.5)#s表示点的大小,c表示颜色,用T的值来给c上色
plt.xlim(-1.5,1.5)
plt.xticks([])
plt.ylim(-1.5,1.5)
plt.yticks([])
plt.xlabel("X")
plt.ylabel("Y")
plt.title("scatter")
#bar
fig.add_subplot(332)
n=10
X=np.arange(n)
Y1=(1-X/float(n))*np.random.uniform(0.5,1.0,n)
Y2=(1-X/float(n))*np.random.uniform(0.5,1.0,n)
plt.bar(X,+Y1,facecolor='#9999ff',edgecolor='red')
#+Y1表示把柱状图画在横轴上面;facecolor配置柱子颜色;edgecolor配置柱子边缘颜色
plt.bar(X,-Y2,facecolor='#ff9999',edgecolor='green')
#-Y2表示把柱状图画在横轴下面;
for x,y in zip(X,Y1):
plt.text(x+0.4, y+0.05, '%.2f'%y, ha='center', va='top')
#添加注释;x+0.4, y+0.05表示注释的位置;'%.2f'%y表示注释的格式;
#ha='center'注释的水平位置;va='bottom'注释在条的位置,top表示在条的里面,bottom表示在条的上面(外面)
for x,y in zip(X,Y2):
plt.text(x+0.4, -y-0.05, '%.2f'%y, ha='center', va='top') #Pie
fig.add_subplot(333)
n=20
Z=np.ones(n)
Z[-1]*=2
plt.pie(Z,explode=Z*.05,colors=['%f'%(i/float(n)) for i in range(n)],
labels=['%.2f'%(i/float(n)) for i in range(n)])
#plt.pie传入一个数组;explode=Z*.05表示每一个扇形里中心的距离;colors=['%f'%设置的为灰度颜色;
#labels=标签,在此打印为颜色的值
plt.gca().set_aspect('equal')#set_aspect('equal')成为一个正的圆形,不是为椭圆
plt.xticks()
plt.yticks()
#Polar
fig.add_subplot(334,polar=True)#polar=True为下面plt.plot(theta,radii)话极坐标图,做铺垫
#否则的话,为折线图
n=20
theta=np.arange(0.0,2*np.pi,2*np.pi/n)#0-2pi;2*np.pi/n为间隔
radii=10*np.random.rand(n)#radii为半径
plt.plot(theta,radii)
#或者为plt.polar(theta,radii)
#plt.polar(theta,radii) #heatmap热图
fig.add_subplot(335)
from matplotlib import cm
data=np.random.rand(3,3)
cmap=cm.Blues#指定颜色cmap=cmap表示color map
map=plt.imshow(data, interpolation='nearest', cmap=cmap,aspect='auto',vmin=0,vmax=1)
#interpolation='nearest'表示最近插值 ;vmin=0,vmax=1代表颜色的调整;aspect='auto'自动调整大小;
#
#3D图
from mpl_toolkits.mplot3d import Axes3D
ax=fig.add_subplot(336,projection="3d")
ax.scatter(1,1,3,s=100) #hot map 热力图
fig.add_subplot(313)#横跨3个位置
def f(x,y):
return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2)
n=256
x=np.linspace(-3,3,n)
y=np.linspace(-3,3,n)
X,Y=np.meshgrid(x,y)
plt.contourf(X,Y,f(X,Y),8,alpha=.75,cmap=plt.cm.hot)
plt.savefig("./data/fig.png")#保存图形
plt.show()#显示图

matplotlib绘图3的更多相关文章

  1. matplotlib 绘图

    http://blog.csdn.net/jkhere/article/details/9324823 都打一遍 5 matplotlib-绘制精美的图表 matplotlib 是python最著名的 ...

  2. python实战学习之matplotlib绘图续

    学习完matplotlib绘图可以设置的属性,还需要学习一下除了折线图以外其他类型的图如直方图,条形图,散点图等,matplotlib还支持更多的图,具体细节可以参考官方文档:https://matp ...

  3. matplotlib绘图的基本操作

    转自:Laumians博客园 更简明易懂看Matplotlib Python 画图教程 (莫烦Python)_演讲•公开课_科技_bilibili_哔哩哔哩 https://www.bilibili. ...

  4. python中利用matplotlib绘图可视化知识归纳

    python中利用matplotlib绘图可视化知识归纳: (1)matplotlib图标正常显示中文 import matplotlib.pyplot as plt plt.rcParams['fo ...

  5. matplotlib绘图基本用法-转自(http://blog.csdn.net/mao19931004/article/details/51915016)

    本文转载自http://blog.csdn.net/mao19931004/article/details/51915016 <!DOCTYPE html PUBLIC "-//W3C ...

  6. python实战学习之matplotlib绘图

    matplotlib 是最流行的Python底层绘图库,主要做数据可视化图表 可以将数据可视化,能够更直观的呈现数据 matplotlib绘图基本要点 首先实现一个简单的绘图 # 导入pyplot f ...

  7. 【原】在Matplotlib绘图中添加Latex风格公式

    Matplotlib绘图的过程中,可以为各个轴的Label,图像的Title.Legend等元素添加Latex风格的公式. 只需要在Latex公式的文本前后各增加一个$符号,Matplotlib就可以 ...

  8. Matplotlib绘图双纵坐标轴设置及控制设置时间格式

    双y轴坐标轴图 今天利用matplotlib绘图,想要完成一个双坐标格式的图. fig=plt.figure(figsize=(20,15)) ax1=fig.add_subplot(111) ax1 ...

  9. ssh调用matplotlib绘图报错RuntimeError: Invalid DISPLAY variable

    1.问题:在本地用matplotlib绘图可以,但是在ssh远程绘图的时候会报错 RuntimeError: Invalid DISPLAY variable 2.原因:matplotlib的默认ba ...

  10. Matplotlib绘图及动画总结

    目录 Matplotlib绘图总结 绘图原理 block模式(python默认) interactive模式(ipython模式默认) 深入子图 子图表示 子图绘图 绘制动画 参考链接 Matplot ...

随机推荐

  1. 流程控制之for

    for循环是 迭代式循环,其强大之处在于循环取值 用法一: l = [1, 2, 3, 4, 5, 5, 6, 5, 4, 3] for x in l: print(x) info = {'} for ...

  2. Maven快照机制(SNAPSHOT)

    文章转自 http://www.cnblogs.com/EasonJim/p/6852840.html 以下引用自https://ayayui.gitbooks.io/tutorialspoint-m ...

  3. PAT A1149 Dangerous Goods Packaging (25 分)——set查找

    When shipping goods with containers, we have to be careful not to pack some incompatible goods into ...

  4. python 数据结构 队列(queue)

    如需转发,请注明出处:小婷儿的python https://www.cnblogs.com/xxtalhr/p/10293817.html 欢迎关注小婷儿的博客: 有问题请在博客下留言或加作者微信:t ...

  5. Html5 手机端网页不允许缩放

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

  6. stm32cubemx学习要点记录

    如果有些外设的HAL库函数找不到的话,你可以到IAR工程的文件夹显示栏中找如下图所示:

  7. 【Codeforces 1120A】Diana and Liana

    Codeforces 1120 A 题意:给\(n\)个数\(a_1..a_n\),要从其中删去小于等于\(n-m\times k\)个数,使得将这个数组分成\(k\)个一段的序列时有至少一段满足以下 ...

  8. MySQL(六)常用语法和数据类型

    阅读MySQL语法时,需要注意的规则: ①符号用来指出几个选择中的一个,比如:null | not null表示或者给出null或者给出not null: ②包含在方括号中的关键字或子句(如[like ...

  9. Android java.lang.RuntimeException: Unable to instantiate activity ComponentInfo 特殊异常

    本来是不想写的,因为这个异常太常见了,而且也容易处理.但是还是决定记录一下,因为之前遇到过,没留心,今天又遇到了,苦逼了,想了好大一会儿才想起来. 通常容易找的就不写了,今天写个特殊的. 现象:当你在 ...

  10. curl NSS error -8179 (SEC_ERROR_UNKNOWN_ISSUER)

    尝试分析 首先根据提示,我判断是CA证书过期.于是对证书进行了更新 update-ca-trust 但是依然没有解决问题.之后,尝试了很多方法后,重新回来想想,为什么不适用curl -v来获取更多信息 ...