9), frameon = False) # Create a twin axix that shares the x-axis ax_twin = axes.twinx() ax_ot(x, fun_cos_x, label = '$e^ # - Values for plotting - n = 1000 # Number of points r_min, r_max =. 5) a.set_xlim( -np.pi, np.pi) plt.tight_layout() plt.savefig( 'multi-plots-02.png') plt.show()įrom matplotlib import pyplot as plt import numpy as np # - Generate cosine and sine values -# x = np.linspace( -np.pi, np.pi, num = 200, endpoint = True) cos_x = np.cos(x) fun_cos_x = np.exp( -x) *np.cos( 5 *x) # - Plot the data -# fig, axes = plt.subplots(figsize =( 10, 5)) ot(x, cos_x, label = '$ \\ cos x$', color = 'black', linestyle = '-') axes.fill_between(x, cos_x, - 1, alpha =. 125) t_title( 'Function with Sine') t_xlim( -np.pi, np.pi) t_xlabel( 'Angle (radians)') t_xlabel( 'Angle (radians)') t_ylim( - 1, 1) t_ylim( - 1, 1) t_ylim( - 20, 15) t_ylim( - 20, 15) for a in axes.flat: # 'flat', 'opens' the 2D list into a simple 1D list a.grid(alpha =. 125) t_title( 'Function with Cosine') t_xlim( -np.pi, np.pi) # Plot 0,1 : Function with Sine ot(x, fun_sin_x, color = 'g') axes.fill_between(x, fun_sin_x, 0, color = 'g', alpha =. From matplotlib import pyplot as plt import numpy as np #- Generate cosine and sine values -# x = np.linspace( -np.pi, np.pi, num = 100, endpoint = True) cos_x = np.cos(x) sin_x = np.sin(x) fun_cos_x = np.exp( -x) *np.cos( 5 *x) fun_sin_x = np.exp( -x) *np.sin( 5 *x) #- Plot the data -# fig, axes = plt.subplots(nrows = 2, ncols = 2, figsize =( 12, 8), sharex = 'col', sharey = 'row') # Plot 0,0 : Cosines ot(x, cos_x, color = 'r', label = 'cos x') ot(x, cos_x ** 2, color = 'grey', linestyle = '-', label = 'cos$^2$ x') t_title( 'Cosine x
0 Comments
Leave a Reply. |