Python Plotting Basics
Python Plotting Basics
x = [1, 2, 3, 4]
y = [2, 4, 1, 3]
plt.plot(x, y)
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.grid(True)
plt.show()
import pandas as pd
data = {'Month': ['Jan', 'Feb', 'Mar', 'Apr'], 'Sales': [100, 120, 90, 110]}
df = pd.DataFrame(data)
plt.ylabel("Sales")
plt.grid(True)
plt.show()
plt.plot(x, y, color='green', linestyle='--', marker='s') # dashed green line with square markers
plt.title("Customized Line Plot")
plt.show()
values = [5, 7, 3]
plt.ylabel("Value")
plt.show()
tips = sns.load_dataset("tips")
plt.title("Bill vs Tip")
plt.show()
axs[0].set_title("Plot 1")
plt.tight_layout()
plt.show()
import numpy as np
data = np.random.randn(1000)
plt.title("Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
plt.show()
corr = tips.corr(numeric_only=True)
plt.title("Correlation Heatmap")
plt.show()