Matplotlib_Complete_Notes
Matplotlib_Complete_Notes
What is Matplotlib?
Matplotlib is a Python library used for creating static, animated, and interactive visualizations. It is widely used
for data visualization and works well with other libraries like NumPy and Pandas.
Installation
Importing Pyplot
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
plt.plot(x, y)
plt.title("Simple Line Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
Matplotlib Complete Notes with Examples
Customization Options
- Title: plt.title("Title")
- Axis Labels: plt.xlabel("X"), plt.ylabel("Y")
- Grid: plt.grid(True)
- Legend: plt.legend()
- Line styles, markers, and colors can be customized.
Saving Plots
plt.savefig("filename.png")
ax2 = ax1.twinx()
ax2.plot(months, growth)
import plotly.express as px
fig = px.line(df, x='Month', y='Sales')
fig.show()