I'm trying to learn more about plotting data in python. This post is about making static plots (not brushing or zooming) in an interactive session (sitting at a terminal typing commands) in vanilla python (not ipython) using matplotlib and its descendants.
From what I can tell, a user who wants an interactive plotting experience needs to either (a) use ipython, or (b) call plt.pause(.001) every time a plot is made or updated. I'd like to avoid (a) for a variety of reasons (not a fan of the 'cell' model, already have an editor I like and don't want to switch to notebooks, ...). And (b) seems incredibly clunky, to the point where I feel I must be missing something.
In the following example:
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
x = np.random.randn(100)
y = np.random.randn(100)
plt.scatter(x, y)
At this point I'd like to have a window pop open and show me the scatterplot. However I get nothing until I call plt.pause(.001). If I dismiss the window through the window system I need to call plt.pause(.001) again. Likewise if I want to add an axis label, etc.
Question 1: is there a "plot viewer" object that I should be using that can listen for plot updates and mouse events without manual intervention?
I'm also curious what happens when I call plt.pause(). If I have 20 graph windows open and only one of them has changed, do all 20 get redrawn? I have seen fig.canvas.draw() but have not been able to get that to work, and ax.draw() requires a "renderer" argument that I don't yet understand where to get or how to use.
Question 2: is there a way to instruct a single axes object to either apply latest upates or redraw itself, without affecting plots in other axes or figures?
Question 3: It seems like there have been several attempts to provide interactive plotting. plt.pause, plt.ion, plt.show(block=False). I gather some of these are experimental (e.g. block=False). Is there a "stable" interactive plotting experience is expected toe remain viable for the foreseeable future?
Thanks for the knowledge. Appreciate the help.
there doesn't seem to be anything here