Here are examples of various types of plots, diagrams, and graphs you can create in Python using popular libraries like Matplotlib, Seaborn, and Plotly:
Basic Plots with Matplotlib
python
import matplotlib.pyplot as plt
import numpy as np
# Line Plot
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.figure(figsize=(10, 6))
plt.plot(x, y, 'b-', label='sin(x)')
plt.plot(x, np.cos(x), 'r--', label='cos(x)')
plt.xlabel('X values')
plt.ylabel('Y values')
plt.title('Sine and Cosine Functions')
plt.legend()
plt.grid(True)
plt.show()
# Scatter Plot
np.random.seed(42)
x = np.random.randn(100)
y = 2 * x + np.random.randn(100) * 0.5
plt.figure(figsize=(8, 6))
plt.scatter(x, y, alpha=0.6, c=x, cmap='viridis')
plt.colorbar(label='X values')
plt.xlabel('X')
plt.ylabel('Y')
plt.title('Scatter Plot with Color Mapping')
plt.show()
# Bar Chart
categories = ['A', 'B', 'C', 'D', 'E']
values = [23, 45, 56, 78, 32]
plt.figure(figsize=(8, 6))
plt.bar(categories, values, color='skyblue', edgecolor='navy')
plt.xlabel('Categories')
plt.ylabel('Values')
plt.title('Bar Chart Example')
plt.show()
# Histogram
data = np.random.normal(100, 15, 1000)
plt.figure(figsize=(8, 6))
plt.hist(data, bins=30, color='green', alpha=0.7, edgecolor='black')
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.title('Histogram of Normal Distribution')
plt.show()
These examples demonstrate a wide variety of plotting capabilities in Python. Each type of visualization is suited for different kinds of data and analysis needs. You can customize colors, styles, labels, and many other properties to create publication-quality figures for your specific requirements.