Wednesday, October 20, 2010

Plotting using Matplotlib

Share axis between two subplots

In order to share the x-axis between two subplot:

import pylab as p
fig = p.figure()
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212, sharex=ax1)


Plotting the lines before the points
In a plot with several sets of points and lines connecting each set, in order to plot the points on top of the lines (so that the line doesn't show inside the point) use:

R=range(1,10)
P=range(1,10)
p.plot(R,P,color='0.2',lw=1.5, zorder=1)
p.scatter(R,P,s=150,color=c, zorder=2)

No comments:

Post a Comment