Skip to content

Plotting in Python

plotting

data visualization with matplotlib. data visualization with seaborn.

creating a simple plot with matplotlib :

import numpy as np
import matplotlib.pyplot as plt
data = np.arange(10)

plt.plot(data)

Figure and subplots

plots in matplotlib resides within the figure object.

a figure object can be created with the figure method.

fig = plt.figure()
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)
ax4 = fig.add_subplot(2, 2, 4)
fig.savefig("subplots.jpg")

black dashed graph can be drawn by providing the flag : k--