【问题标题】:Python: Change the label of a matplotlib button on clickPython:单击时更改matplotlib按钮的标签
【发布时间】:2014-07-05 12:39:22
【问题描述】:

如何在单击 matplotlib 按钮时更改其标签?就像我有一个带有“之前”标签的 matplotlib 按钮一样,我想单击它并将标签更改为“之后”。我该怎么做呢?我觉得我应该知道这一点,但我真的在网上或文档中找不到任何东西。

【问题讨论】:

标签: python button matplotlib label


【解决方案1】:

假设这个例子http://matplotlib.org/1.3.1/examples/widgets/buttons.html

bprev.label="A new Label!" #actually this doesnt work...

我只是通过查看文档(实际上只是看了一眼)http://matplotlib.org/1.3.1/api/widgets_api.html#Button

更多的实验让我明白了

bprive.label.set_text("A new label") # works

【讨论】:

  • 您可能必须在ion() 上设置交互模式,我认为...否则它实际上不会更新图像
  • 也没有用。也许我会尝试别的。感谢您的回答!
  • @lkloh 查看编辑:P 显然我最初是错的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-28
  • 2019-12-03
  • 1970-01-01
  • 2014-02-16
相关资源
最近更新 更多