matplotlib plt

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,3)
ax4 = fig.add_subplot(2,2,4)
#plt.figure()
ax1.hist(np.random.randn(100),bins=20,color='k',alpha=0.3)
ax2.scatter(np.arange(30),np.arange(30)+3*np.random.randn(30))
# fig,axes = plt.subplots(2,3)
# _=axes[0,1].hist(np.random.randn(100),bins=20,color='k',alpha=0.3)
ax3.plot(np.random.randn(30).cumsum(),color='k',linestyle='--',marker='o')
plt.plot(np.random.randn(40).cumsum(),"k--")
plt.show()

fig = plt.figure()
ax1= fig.add_subplot(1,2,1)
ax1.plot(np.random.randn(1000).cumsum())
ticks = ax1.set_xticks([0,250,500,750,1000])  #设置刻度
labels = ax1.set_xticklabels(["one","two","three","four","five"],rotation=30,fontsize="small") #设置标签
ax1.set_title("hello world") #设置标题

#fig = plt.figure()
ax = fig.add_subplot(1,2,2)
ax.plot(np.random.randn(1000).cumsum(),label="a")
ax.plot(np.random.randn(1000).cumsum(),label="b")
ax.plot(np.random.randn(1000).cumsum(),label="c")
ax.legend(loc="best")
plt.show()
小小拼图
领取红包

支付宝扫一扫

支付宝红包

红包