python中的图形从技术上讲打印出3条垂直线。但是,只有一个可见

时间:2019-04-22 18:04:16

标签: numpy matplotlib

我在python中有一个文件,在该文件中,您会看到一个绘制的图,该图从技术上讲会打印出3条垂直线。但是,我只能看到它们...我不想只使用plt.xlim(right = 5)

来放大

我尝试放大并且线条可见,但是我看不到完整图片

import matplotlib.pyplot as plt
from scipy.stats import norm

plt.hist(portfolio, 50, density=True, facecolor='g', alpha=.5)

xt = plt.xticks()[0]  
xmin, xmax = min(xt), max(xt)  
lnspc = np.linspace(xmin, xmax, len(portfolio))

m, s = np.mean(portfolio),np.std(portfolio) # get mean and standard deviation  
pdf_g = norm.pdf(lnspc, m, s) # now get theoretical values in our interval  
plt.plot(lnspc, pdf_g, label='Norm')

VaR1,VaR5,VaR10 = pr_var(1,2,7)
plt.vlines(VaR1, colors='k', ymin=0, ymax=.01)
plt.vlines(VaR5, colors='b', ymin=0, ymax=.01)
plt.vlines(VaR10, colors='r', ymin=0, ymax=.01)

plt.legend(('Sim.Distribution', '1% VaR', '5% VaR','10% `aR'),loc='best')
plt.text(xmin,norm.pdf(m, m, s), r'$\\mu='+str(round(m,4))+',\\ \\sigma='+str(round(s,4))+'$')

plt.savefig('var-thing.png', bbox_inches='tight')
plt.show()

0 个答案:

没有答案