Reputation: 522
i have to plot eeg data of 3 different channels in my graph. I would like to plot of all of them in one figure seperated by horozintal lines. X axis common to all the channels.
I can do this easily by using add_axes. But i want to draw a vertical line intersecting these axes. But i m not able to do it.
Currently, my sample code look like this.
from pylab import figure, show, setp
from numpy import sin, cos, exp, pi, arange
t = arange(0.0, 2.0, 0.01)
s1 = sin(2*pi*t)
s2 = exp(-t)
s3 = 200*t
fig = figure()
t = arange(0.0, 2.0, 0.01)
yprops = dict(rotation=0,
horizontalalignment='right',
verticalalignment='center',
x=-0.1)
axprops = dict(yticks=[])
ax1 =fig.add_axes([0.1, 0.5, 0.8, 0.2], **axprops)
ax1.plot(t, s1)
ax1.set_ylabel('S1', **yprops)
axprops['sharex'] = ax1
#axprops['sharey'] = ax1
# force x axes to remain in register, even with toolbar navigation
ax2 = fig.add_axes([0.1, 0.3, 0.8, 0.2], **axprops)
ax2.plot(t, s2)
ax2.set_ylabel('S2', **yprops)
ax3 = fig.add_axes([0.1, 0.1, 0.8, 0.2], **axprops)
ax3.plot(t, s3)
ax3.set_ylabel('S3', **yprops)
# turn off x ticklabels for all but the lower axes
for ax in ax1, ax2:
setp(ax.get_xticklabels(), visible=False)
show()
I want my final image to look like the one below. In my current output, i can get the same graph without the green vertical line.
can any one please help ??? I dont want to use subplots and also i dont want to add axvline for each axes.
Thank u, thothadri
Upvotes: 1
Views: 652
Reputation: 87376
use
vl_lst = [a.axvline(x_pos, color='g', lw=3, linestyle='-') for a in [ax1, ax2, ax3]]
to update for each frame:
new_x = X
for v in vl_lst:
v.set_xdata(new_x)
Upvotes: 1