Skip to content

Instantly share code, notes, and snippets.

@adxrgh
Last active April 16, 2019 09:37
Show Gist options
  • Save adxrgh/6943630e4ccc4ea8d8b736506de0af98 to your computer and use it in GitHub Desktop.
Save adxrgh/6943630e4ccc4ea8d8b736506de0af98 to your computer and use it in GitHub Desktop.
[双图显示概率分布]利用kde、hist,cumlative画双图 #plot
import matplotlib.pyplot as plt
from datetime import datetime as dt
import os
now =dt.now().strftime('%Y%m%d_%H_%M_%S')
fig = plt.figure()
ax = fig.add_subplot(211)
data = pd.Series(np.random.randn(500),name='random 500')
data.plot(kind='kde',color='b',alpha=.6,ax=ax) #需要scipy.stats包
#以下使用的是matplot的方法
data.hist(color='b',alpha=.6,ax=ax,normed=True)
ax.set_title = ('kde histgram &cdf')
ax = fig.add_subplot(212)
data.hist(ax=ax,normed=True,cumulative=True)
plt.legend()
fig.savefig(now+'.png')
os.system('start '+now+'.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment