forked from Snailclimb/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo8.py
More file actions
27 lines (22 loc) · 471 Bytes
/
demo8.py
File metadata and controls
27 lines (22 loc) · 471 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
"""
绘制散点图
"""
import numpy as np
import matplotlib.pyplot as plt
# 数据个数
n = 1024
# 均值为0, 方差为1的随机数
x = np.random.normal(0, 1, n)
y = np.random.normal(0, 1, n)
# 计算颜色值
color = np.arctan2(y, x)
# 绘制散点图
plt.scatter(x, y, s = 75, c = color, alpha = 0.5)
# 设置坐标轴范围
plt.xlim((-1.5, 1.5))
plt.ylim((-1.5, 1.5))
# 不显示坐标轴的值
plt.xticks(())
plt.yticks(())
plt.show()