How To Draw Multiple Line Graph By Using Matplotlib In Python
I want to create a Full 12 Leads EKG graph by using matplotlib in Python 2.7, so I had already wrote down some code to represent each lead (using subplot), but it have an issue abo
Solution 1:
Here is a simple example, where all lines are plotted in the same axes, but offset by 3 units in y direction.
import matplotlib.pyplot as plt
import numpy as np; np.random.seed(1)
s=3
x = np.linspace(0,10,2000)
a = np.sin(np.cumsum((np.random.normal(scale=0.1, size=(len(x), 12))), axis=0))
fig, ax = plt.subplots()
for i inrange(a.shape[1]):
ax.plot(x, a[:,i]+s*i)
labels = ["PG{}".format(i) for i inrange(a.shape[1])]
ax.set_yticks(np.arange(0,a.shape[1])*s)
ax.set_yticklabels(labels)
for t, l inzip(ax.get_yticklabels(), ax.lines):
t.set_color(l.get_color())
plt.show()
Post a Comment for "How To Draw Multiple Line Graph By Using Matplotlib In Python"