Reputation: 751
I'm trying to plot a cdf with matplotlib. However, cdfs begin in the origin, thus I prepended zeros to the x and y arrays. The problem is now that the origin now is marked as a data point. I'd like to remove that single marker in the point (0,0).
Code and picture below.
#Part of the myplot (my own) class
def cdf(self):
markers = ["x","v","o","^","8","s","p","+","D","*"]
for index,item in enumerate(np.asarray(self.data).transpose()):
x = np.sort(item)
y = np.arange(1,len(x)+1) / len(x)
x = np.insert(x,0,0)
y = np.insert(y,0,0)
self.plot = plt.plot(x,
y,
marker=markers[index],
label=self.legend[index])
self.setLabels( xlabel=self.xlabel,
ylabel="cumulative density",
title=self.title)
self.ax.set_ylim(ymax=1)
Upvotes: 0
Views: 1738
Reputation: 339102
You cannot remove a marker. What you may do is to plot all the markers first, then append the origin and then plot a line.
x = np.sort(item)
y = np.arange(1,len(x)+1) / len(x)
self.plot, = plt.plot(x, y, marker=markers[index], ls="", label=self.legend[index])
x = np.insert(x,0,0)
y = np.insert(y,0,0)
self.plot2, = plt.plot(x, y, marker="", color=self.plot.get_color())
Alternative: Use the markevery
argument.
x = np.sort(item)
y = np.arange(1,len(x)+1) / len(x)
x = np.insert(x,0,0)
y = np.insert(y,0,0)
markevery = range(1, len(x))
self.plot, = plt.plot(x, y, marker=markers[index], markevery=markevery,
ls="", label=self.legend[index])
Upvotes: 1