import numpy as np
import matplotlib.pyplot as plt
def main():
#scatter
fig = plt.figure()
ax = fig.add_subplot(3,3,1)
n = 128
X = np.random.normal(0,1,n)
Y = np.random.normal(0,1,n)
T = np.arctan2(Y,X)
#plt.axes([0.025,0.025,0.95,0.95])
ax.scatter(X,Y,s=75,c=T,alpha=.5)
plt.xlim(-1.5,1.5), plt.xticks([])
plt.ylim(-1.5,1.5), plt.yticks([])
plt.axis()
plt.title('scatter')
plt.xlabel('x')
plt.ylabel('y') #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='white')
plt.bar(X, -Y2, facecolor='#ff9999', edgecolor='white')
for x,y in zip(X,Y1):
plt.text(x + 0.4, y + 0.05,'%.2f' %y,ha='center', va = '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.gca().set_aspect('equal')
plt.xticks([]),plt.yticks([]) #polar
fig.add_subplot(334,polar =True)
n = 20
theta = np.arange(0.0, 2* np.pi, 2*np.pi /n)
radii = 10 * np.random.rand(n)
# plt.plot(theta, radii)
plt.polar(theta,radii)
#heatmap
fig.add_subplot(335)
from matplotlib import cm
data = np.random.rand(3,3)
# print(data)
cmap =cm.Blues
map= plt.imshow(data,interpolation='nearest',cmap=cmap,aspect='auto',vmin=0,vmax=1)
#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)
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('D:/fig.png')
plt.show() if __name__ == '__main__':
main()

最新文章

  1. 适配器模式 - Adapter
  2. kxbdSuperMarquee.js滚动的神器-推荐
  3. mysqlnd cannot connect to MySQL 4.1+
  4. SQL Server(四)——查询练习(45道习题)
  5. Mysql游标
  6. 【译】Android系统简介
  7. 2D游戏编程3—GDI
  8. js类封装
  9. java之NIO编程
  10. JAVA邮件收发实现(待)
  11. Canvas rotate- 旋转
  12. 读书共享 Primer Plus C-part 5
  13. 在Linux服务器部署 .NET-Core 项目
  14. 【AutoFac】依赖注入和控制反转的使用
  15. Project D | Digital life
  16. Leetcode 143. Reorder List(Medium)
  17. 转载 IEnumerable和IEnumerator 详解
  18. 关于jmeter命令行执行.jmx文件出现Error in NonGUIDriver java.lang.RuntimeException: Could not find the TestPlan c
  19. TXB0108 TXS0108E 8-Bit Bidirectional Voltage-Level Translator for Open-Drain and Push-Pull Applications
  20. 未能加载文件或程序集“Oracle.DataAccess”或它的某一个 依赖项。如何解决?

热门文章

  1. 第一个OC类
  2. Linux Shell中的数组及遍历 转
  3. IO复习
  4. 总结tomcat的核心组件以及根目录结构
  5. 稳过!华为微认证ModelArts实现智能花卉识别稳过!
  6. iOS组件化之-给自己的组件添加资源文件
  7. ansible手动添加模块
  8. CentOS7利用yum缓存搭建本地源
  9. 基于nodejs的阿里云DDNS服务,支持多网卡绑定
  10. RFC2899广播帧转发测试——网络测试仪实操