Description
matplotlib.pyplot.draw()
…
This is used in interactive mode to update a figure that has been altered, but not automatically re-drawn. This should be only rarely needed, but there may be ways to modify the state of a figure with out marking it as stale. Please report these cases as bugs.
It appears that using Line2D.set_color
does not cause matplotlib to re-render the figure. This means calling matplotlib.pyplot.draw()
or fig.canvas.draw_idle()
is required when changing the line color on a plot interactively.
-
Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
- Python version: 3.5.2
- Matplotlib version: 1.5.3
- Platform: Arch Linux 4.8.4 x86-64
-
How did you install Matplotlib and Python (pip, anaconda, from source ...)
- Both via
pacman
(Arch Linux package manager)
- Both via
-
If possible please supply a Short, Self Contained, Correct, Example that demonstrates the issue i.e a small piece of code which reproduces the issue and can be run with out any other (or as few as possible) external dependencies.
import matplotlib import matplotlib.pyplot fig, [ax1, ax2] = matplotlib.pyplot.subplots(2) [line] = ax1.plot([0.0, 1.0], color="red") button = matplotlib.widgets.Button(ax2, "Greenify") def button_on_clicked(event): line.set_color("green") #fig.canvas.draw_idle() button.on_clicked(button_on_clicked) matplotlib.pyplot.show()
- Click the button. Avoid moving the mouse after clicking the button.
- Expected: The color should turn green. Actuality: It stays red. (It can turn green if you move your mouse, however.)
-
If this is an image generation bug attach a screenshot demonstrating the issue.
-
If this is a regression (Used to work in an earlier version of Matplotlib), please
note where it used to work.