【几点收获】
1.学习了均匀状态下的子图和非均匀状态下的子图两种绘图方式
2.对子图上添加网格线、直线以及轴的坐标表示方法有了初步的掌握
3.对如何画出风玫瑰图有了一定的启示
【思考题】墨尔本1981年至1990年的每月温度情况数据集来自github仓库下data/layout_ex1.csv,请利用数据,画图。
日后解决,还未能学好numpy和掌握如何引用github仓库中的内容。
【思考题】用 np.random.randn(2, 150)
生成一组二维数据,使用两种非均匀子图的分割方法,做出该数据对应的散点图和边际分布图
第一种方法:使用add_gridspec做分割,通过width_ratios和height_ratios对图像进行调整,将图像分为四个区域,然后对每一块区域进行构建
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False #用来正常显示负号
datax,datay = np.random.randn(2,150)
fig = plt.figure(figsize = (8,8))
spec = fig.add_gridspec(nrows = 2,ncols = 2,width_ratios = [8,1],height_ratios = [1,8])
ax1 = fig.add_subplot(spec[0,0])
ax1.hist(datax,density = True,rwidth = 0.8)
ax