Sunday, March 29, 2020

change line types and colors of the plot of matplotlib library in datascience using python

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

axes = plt.axes()
axes.set_xlim([-5,5])
axes.set_ylim([0,1.0])
axes.set_xticks([-5,-4,-3,-2,-1,0,1,2,3,4,5])
axes.set_yticks([0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0])
axes.grid()
plt.plot(x, norm.pdf(x),'b-')
plt.plot(x,norm.pdf(x, 1.0, 0.5), 'g:')

plt.savefig('C:\\Users\\Onyx1\\Pictures\\matplotlib\\matplot_x_y_ticks_bg_grid.jpg', format='jpg')
plt.show()

output:

No comments:

Post a Comment

python class topic video