Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- x = [1, 2, 3, 4, 5]
- y = [10, 12, 8, 14, 11]
- plt.plot(x, y, marker='o', linestyle='--', color='green')
- plt.title('Line Plot Example')
- plt.xlabel('X-axis')
- plt.ylabel('Y-axis')
- plt.grid(True)
- plt.show()
- -----------------------------------------------------------
- import seaborn as sns
- import pandas as pd
- data = pd.DataFrame({
- 'Item': ['Apple', 'Banana', 'Carrot'],
- 'Quantity': [10, 5, 8]
- })
- sns.barplot(x='Item', y='Quantity', data=data, hue='Item', legend=False)
- plt.title("Bar Chart with Color Palette")
- plt.show()
- ------------------------------------------------------------
- sns.boxplot(data=[10, 20, 25, 30, 80])
- plt.title("Box Plot Showing Outlier")
- plt.show()
- -----------------------------------------------------------
- df = sns.load_dataset("iris")
- correlation = df.corr(numeric_only=True)
- sns.heatmap(correlation, annot=True, cmap='coolwarm')
- plt.title("Heatmap of Iris Dataset Correlation")
- plt.show()
- ---------------------------------------------------------------
- sns.pairplot(df, hue='species')
- plt.suptitle("Pairplot with Hue = Species", y=1.02)
- plt.show()
- ------------------------------------------------------
- sns.histplot(df['sepal_length'], kde=True, color='orange')
- plt.title("Distribution Plot of Sepal Length")
- plt.show()
- ---------------------------------------------------------
- plt.plot([1, 2, 3], [4, 5, 6])
- plt.annotate('Peak Point', xy=(2, 5), xytext=(2.5, 5.5),
- arrowprops=dict(facecolor='black', shrink=0.05))
- plt.title("Plot with Annotation")
- plt.show()
- ---------------------------------------------------------
- sizes = [40, 35, 25]
- labels = ['Apple', 'Banana', 'Carrot']
- colors = ['#ff9999','#66b3ff','#99ff99']
- plt.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=140)
- plt.title("Pie Chart of Fruit Distribution")
- plt.axis('equal')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment