繁体   English   中英

Matplotlib:删除单个标记

[英]Matplotlib: Remove Single Marker

我正在尝试使用matplotlib绘制CDF。 但是,cdfs是从原点开始的,因此我在x和y数组前加了零。 现在的问题是,原点现在被标记为数据点。 我想删除点(0,0)中的单个标记。

下面的代码和图片。

#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)

在此处输入图片说明

您无法删除标记。 您可能要做的是先绘制所有标记,然后附加原点,然后绘制一条线。

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())

备选:使用markevery参数。

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])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM