Matplotlib: Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted Mobile edit Mobile web edit
Undid revision 1253482272 by 49.147.121.219 (talk)
Tags: Undo Mobile edit Mobile web edit Advanced mobile edit
Line 35:
[[Matplotlib]] supports various types of 2 dimensional and 3 dimensional plots. The support for two dimensional plots is robust. The support for three dimensional plots was added later and while it is good, it is not as robust as 2 dimensional plots.
 
===Examples===
import matplotlib.pyplot as plt
<gallery mode="packed">
import statistics
File:Synchrotron Functions.svg|Line plot
 
File:Matplotlib histogram v.svg|Histogram
UA_data = [301, 311, 294, 279, 275, 285, 302, 308, 295, 297, 315, 312, 316, 316, 311, 304, 298, 292, 288, 300]
File:Matplotlib scatter v.svg|Scatter plot
days = range(1, 21)
File:Matplotlib 3d v.svg|3D plot
mean_UA = statistics.mean(UA_data)
File:Mpl example qbo.svg|Image plot
stdev_UA = statistics.stdev(UA_data)
File:Mpl example Helmoltz coils.svg|Contour plot
 
File:Weight Growth of RN First Rate Line-of-Battle Ships 1630-1875.svg|Scatter plot
plt.figure(figsize=(10, 6)) # Adjust figure size as needed
File:Logarithmic Spiral Pylab.svg|Polar plot
plt.plot(days, UA_data, marker='o', linestyle='-')
File:Temp-sunspot-co2.svg|Line plot
plt.axhline(mean_UA, color='r', linestyle='--', label=f'Mean: {mean_UA:.2f}')
File:Mpl example Rosenbrock function.svg|3-D plot
plt.axhline(mean_UA + stdev_UA, color='g', linestyle='--', label=f'Mean + 1SD')
File:Mandelbrot set, plotted with Matplotlib.svg|Image plot
plt.axhline(mean_UA - stdev_UA, color='g', linestyle='--')
</gallery>
plt.axhline(mean_UA + 2 * stdev_UA, color='b', linestyle='--', label=f'Mean + 2SD')
plt.axhline(mean_UA - 2 * stdev_UA, color='b', linestyle='--')
plt.axhline(mean_UA + 3 * stdev_UA, color='k', linestyle='--', label=f'Mean + 3SD')
plt.axhline(mean_UA - 3 * stdev_UA, color='k', linestyle='--')
 
plt.xlabel('Day')
plt.ylabel('Uric Acid Level')
plt.title('Levey-Jennings Chart for Uric Acid')
plt.legend()
plt.grid(True)
plt.show()
 
==Animations==