赞
踩
import matplotlib.pyplot as plt import numpy as np from numpy.random import randn # # 新建一个figure # flg = plt.figure() # # 1个2X2图像 # ax = flg.add_subplot(2, 2, 1) # 实线图 # plt.plot(randn(50).cumsum()) # 虚线形图 # plt.plot(randn(50).cumsum(), 'k--') # 虚折线图 # plt.plot(randn(50).cumsum(), 'ko--') # 散点图 # plt.plot(randn(50).cumsum(), 'k.') # flg, aex = plt.subplots(2, 2, sharex=True, sharey=True) # for i in range(2): # for j in range(2): # aex[i, j].hist(randn(500), bins=50, color='g', alpha=0.5) # plt.subplots_adjust(wspace=0, hspace=0) # flg = plt.figure() # # ax = flg.add_subplot(1, 1, 1) # # 在坐标轴上面画图形,分别是长方形,圆形,三角形。 # rect = plt.Rectangle((0.2, 0.75), 0.4, 0.15, color='k', alpha=0.4) # cirl = plt.Circle((0.7, 0.2), 0.15, color='b', alpha=0.4) # pgon = plt.Polygon([[0.15, 0.15], [0.35, 0.4], [0.2, 0.6]], color='g', alpha=0.4) # # 添加到图形里面 # ax.add_patch(rect) # ax.add_patch(cirl) # ax.add_patch(pgon) # plt.show() # # 保存图片 # plt.savefig('three.svg', dpi=400, bbox_inches='tight')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。