# 散点图

## 散点图介绍

### 散点图绘制

• plt.scatter(x,y) # 以默认的形状颜色等绘制散点图

### 练习1

a = [11,17,16,11,12,11,12,13,10,14,8,13,12,15,14,17,18,21,16,17,30,14,15,15,15,19,21,22,22,22,23]
b = [26,26,28,19,21,17,16,19,18,20,20,19,22,23,17,20,21,20,22,15,11,15,5,13,15,10,11,13,12,13,6]

from matplotlib import pyplot as plt

y_4 = [11,17,16,11,12,11,12,13,10,14,8,13,12,15,14,17,18,21,16,17,30,14,15,15,15,19,21,22,22,22,23]
y_10 = [26,26,28,19,21,17,16,19,18,20,20,19,22,23,17,20,21,20,22,15,11,15,5,13,15,10,11,13,12,13,6]

x = range(1,32) # 4 和10 月 共享 x 31天

# 绘制图形
plt.scatter(x,y_4)
plt.scatter(x,y_10)

# 优化 4，10月份 数据分开

plt.show()


from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"C:\Windows\Fonts\STXINGKA.TTF", size=14) # 找到自带的字体格式

# 优化 4，10月份 数据分开
y_4 = [11,17,16,11,12,11,12,13,10,14,8,13,12,15,14,17,18,21,16,17,30,14,15,15,15,19,21,22,22,22]
y_10 = [26,26,28,19,21,17,16,19,18,20,20,19,22,23,17,20,21,20,22,15,11,15,5,13,15,10,11,13,12,13,6]

x_4 = range(1,31) # 4 月份
x_10 = range(51,82) # 10月份 间隔了 20  20+30---30+31+20

# 绘制图形
plt.scatter(x_4,y_4)
plt.scatter(x_10,y_10)

# 刻度 四月1号.....10月1号.....
x_t = list(x_4) + list(x_10)
# print(x_t)
x_l = ["四月{}号".format(i) for i in x_4] + ["十月{}号".format(i-50) for i in x_10]
plt.xticks(x_t[::4],x_l[::4],rotation=45,fontproperties=font)
# print(x_l)
plt.yticks(fontproperties=font)

plt.show()


• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 打赏

打赏

MiStonebridge

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 举报
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

11-23 246
12-07 407
09-06 2028
01-14 1830
02-17 2154
04-24 1万+
08-13 2万+
10-28 2万+