Matplotlib:如何删除轮廓的clab

2024-05-16 15:36:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我们知道我们可以删除轮廓/轮廓的集合。但是我怎样才能去除轮廓的裂缝呢?在

fig = plt.figure()
ax = fig.add_subplots(111)
for ivalue in range(10):
    values = alldata [ivalue,:,:]
    cs = plt.contour(x,y,vakues)
    cb = plt.clabel(cs, cs.levels)
     # now remove cs
    for c in cs.collections:
        c.remove()
    # but how can I remove cb?
    plt.savefig('%s.png'%ivalue)

第一个png的clabel仍然存在于第二个png中。所以我想同时移除克拉贝尔。在


Tags: inaddforpngfigpltaxcs
1条回答
网友
1楼 · 发布于 2024-05-16 15:36:40

您可以执行与contour行相同的操作。最小示例:

import numpy as np
import matplotlib.pylab as pl

pl.figure()
for i in range(2):
    c  = pl.contour(np.random.random(100).reshape(10,10))
    cl = pl.clabel(c)

    if i == 1:
        pl.savefig('fig.png'.format(i))

结果为双轮廓,标签:

enter image description here

将其更改为:

^{pr2}$

enter image description here

相关问题 更多 >