Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

matplotlib plot data

import matplotlib.pyplot as plt
import numpy as np

x=np.array([0,1,2,3,4,5,6,7], dtype=np.float)
y=np.array([0,1,2,3,3,2,1,0], dtype=np.float)
# if you don't have subfigures
plt.plot(x, y)
plt.xlabel("x")
plt.ylabel("y")
plt.xlim((1,6))
plt.title("Title")
plt.show()


# if you have subfigures
fig, axs = plt.subplots(2, 1, figsize=(10,7))

axs[0].plot(x, y)
axs[0].set_xlabel("x")
axs[0].set_ylabel("y")
axs[0].set_xlim((1,6))
axs[0].set_title("Plot of y as function of x")

axs[1].plot(x, 2*y)
axs[1].set_xlabel("x")
axs[1].set_ylabel("2*y")
axs[1].set_xlim((1,6))
axs[1].set_title("Plot of 2y as function of x")
fig.tight_layout()
plt.show()
 
PREVIOUS NEXT
Tagged: #matplotlib #plot #data
ADD COMMENT
Topic
Name
1+8 =