matplotlib学习7之散点图

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np

n = 1024
# 高斯分布 http://blog.csdn.net/lanchunhui/article/details/50163669
X = np.random.normal(0,1,n)
Y = np.random.normal(0,1,n)
T = np.arctan2(Y,X)# for color value

plt.scatter(X,Y,s=75,c=T,alpha=0.5)
#设置显示范围
plt.xlim(-1.5,1.5)
plt.ylim(-1.5,1.5)
# 去坐标
plt.xticks(())
plt.yticks(())

plt.savefig("/home/xuleilx/workspace/github/github_pages/public/images/dot_map.png")
plt.show()

结果:
dot_map

坚持原创技术分享,您的支持将鼓励我继续创作!