Line Plot
Code:
import [Link] as plt
x = [1, 2, 3, 4, 5]
y = [2, 3, 5, 7, 11]
[Link](x, y)
[Link]('Line Plot')
[Link]('X-axis')
[Link]('Y-axis')
[Link]()
Scatter Plot
Code:
import [Link] as plt
x = [1, 2, 3, 4, 5]
y = [2, 3, 5, 7, 11]
[Link](x, y)
[Link]('Scatter Plot')
[Link]('X-axis')
[Link]('Y-axis')
[Link]()
Bar Plot
Code:
import [Link] as plt
categories = ['A', 'B', 'C', 'D']
values = [3, 7, 8, 5]
[Link](categories, values)
[Link]('Bar Plot')
[Link]('Categories')
[Link]('Values')
[Link]()
Histogram
Code:
import [Link] as plt
import numpy as np
data = [Link](1000)
[Link](data, bins=30)
[Link]('Histogram')
[Link]('Value')
[Link]('Frequency')
[Link]()
Box Plot
Code:
import [Link] as plt
import numpy as np
data = [[Link](100) for _ in range(5)]
[Link](data)
[Link]('Box Plot')
[Link]('Dataset')
[Link]('Value')
[Link]()
Pie Chart
Code:
import [Link] as plt
labels = 'A', 'B', 'C', 'D'
sizes = [15, 30, 45, 10]
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'B')
[Link](sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=140)
[Link]('Pie Chart')
[Link]()
Heatmap
Code:
import [Link] as plt
import numpy as np
data = [Link](10, 10)
[Link](data, cmap='hot', interpolation='nearest')
[Link]('Heatmap')
[Link]()
[Link]()
3D Plot
Code:
import [Link] as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
fig = [Link]()
ax = fig.add_subplot(111, projection='3d')
x = [Link](-5, 5, 100)
y = [Link](-5, 5, 100)
X, Y = [Link](x, y)
Z = [Link]([Link](X**2 + Y**2))
ax.plot_surface(X, Y, Z, cmap='viridis')
[Link]('3D Plot')
[Link]()