I have a simple graph with several sets of points and lines connecting each set. I want the points to be displayed on top of the lines (so that the line does not appear inside the point). Regardless of the order of the plot and scatter calls, this graph comes out the same way and not the way we would like. Is there an easy way to do this?
import math import matplotlib.pyplot as plt def poisson(m): def f(k): e = math.e**(-m) f = math.factorial(k) g = m**k return g*e/f return f R = range(20) L = list() means = (1,4,10) for m in means: f = poisson(m) L.append([f(k) for k in R]) colors = ['r','b','purple'] for c,P in zip(colors,L): plt.plot(R,P,color='0.2',lw=1.5) plt.scatter(R,P,s=150,color=c) ax = plt.axes() ax.set_xlim(-0.5,20) ax.set_ylim(-0.01,0.4) plt.savefig('example.png')
python matplotlib
telliott99 Feb 22 '10 at 21:34 2010-02-22 21:34
source share