A fairly simple example is at:
However, this notebook is two years old and a lot has changed since then. For instance, I used the ivisual package (which predated the vpython package). However, if you import vpython instead of ivisual, I think the code will run.
I used matplotlib to plot data after the simulation’s while loop completed. Thus, I’m not plotting data in realtime with matplotlib. In general, when plotting realtime data, I use vpython's graphing functions. When using matplotlib, I (and my students) store data in lists and then plot the data after the simulation finishes. I don’t know if this is necessary or not. I haven’t tried plotting data in realtime with matplotlib.
Aaron