Dynamic Plotting With Matplotlib BRG Blog
Dynamic Plotting With Matplotlib BRG Blog
ch/blog/)
The weblog of the Block Research Group
(https://block.arch.ethz.ch/blog/feed/)
(http://vimeo.com/blockresearchgroup)
(https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-
(http://block.arch.ethz.ch)
Rhino 5 and new IronPython installations
matplotlib/) (https://block.arch.ethz.ch/blog/2016/12/rhino-5-
Posted on August 4th, 2016,
by tom
in Code (https://block.arch.ethz.ch/blog/category/code/) and-new-ironpython-installations/)
Creating functions dynamically
(https://plus.google.com/share?url=https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with- (https://block.arch.ethz.ch/blog/2016/11/creating-
matplotlib/)
(https://www.facebook.com/sharer.php? functions-dynamically/)
u=https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/)
Bitwise operators in Python
(https://twitter.com/intent/tweet?url=https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with- (https://block.arch.ethz.ch/blog/2016/10/bitwise-
matplotlib/)
(http://www.linkedin.com/shareArticle? operators-in-python/)
mini=true&url=https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/&title=Dynamic Customizing Rhino toolbar button icons
plotting with matplotlib&summary=&source=)
(mailto:?subject=Dynamic plotting with (https://block.arch.ethz.ch/blog/2016/10/customizing-
matplotlib&body=I think you may find this interesting: https://block.arch.ethz.ch/blog/2016/08/dynamic-
rhino-toolbar-button-icons/)
plotting-with-matplotlib/)
PyOpenGL GLUT error
(https://block.arch.ethz.ch/blog/2016/10/pyopengl-
Matplotlib is a great tool to visualise two-dimensional geometric data (and 3D data to some extent). You glut-error/)
can also use it to dynamically visualise the convergence of an iterative solver.
Surprisingly, you don’t need any fancy functionality to accomplish this, such as, for example, the
Archives
FuncAnimation object of the animation package.
December 2016
import matplotlib.pyplot as plt (https://block.arch.ethz.ch/blog/2016/12/)
import time November 2016
import random (https://block.arch.ethz.ch/blog/2016/11/)
ysample = random.sample(xrange(-50, 50), 100) October 2016
(https://block.arch.ethz.ch/blog/2016/10/)
xdata = [] August 2016
ydata = []
(https://block.arch.ethz.ch/blog/2016/08/)
plt.show() July 2016 (https://block.arch.ethz.ch/blog/2016/07/)
June 2016 (https://block.arch.ethz.ch/blog/2016/06/)
axes = plt.gca() February 2016
axes.set_xlim(0, 100)
(https://block.arch.ethz.ch/blog/2016/02/)
axes.set_ylim(-50, +50)
line, = axes.plot(xdata, ydata, 'r-') January 2016
(https://block.arch.ethz.ch/blog/2016/01/)
for i in range(100): October 2015
xdata.append(i)
ydata.append(ysample[i]) (https://block.arch.ethz.ch/blog/2015/10/)
line.set_xdata(xdata) April 2015 (https://block.arch.ethz.ch/blog/2015/04/)
line.set_ydata(ydata) March 2015
plt.draw() (https://block.arch.ethz.ch/blog/2015/03/)
plt.pause(1e-17)
time.sleep(0.1) January 2015
(https://block.arch.ethz.ch/blog/2015/01/)
# add this if you don't want the window to disappear at the end November 2014
plt.show()
(https://block.arch.ethz.ch/blog/2014/11/)
October 2014
(https://block.arch.ethz.ch/blog/2014/10/)
7 Comments (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-
matplotlib/#comments) July 2014 (https://block.arch.ethz.ch/blog/2014/07/)
January 2014
« Running Matlab as a Python subprocess (https://block.arch.ethz.ch/blog/2016/08/running-matlab-as-a-
python-subprocess/) (https://block.arch.ethz.ch/blog/2014/01/)
Computational Geometry in Python (https://block.arch.ethz.ch/blog/2016/08/computational-geometry-in- August 2013
python/) » (https://block.arch.ethz.ch/blog/2013/08/)
November 2012
(https://block.arch.ethz.ch/blog/2012/11/)
7 Responses to “Dynamic plotting with matplotlib”
Categories
Code
1. Aditya says: July 10, 2017 at 11:56 am (https://block.arch.ethz.ch/blog/2016/08/dynamic- (https://block.arch.ethz.ch/blog/category/code/)
plotting-with-matplotlib/#comment-26635)
import matplotlib.pyplot as plt Events
(https://block.arch.ethz.ch/blog/category/events/)
plt.ion() Group
(https://block.arch.ethz.ch/blog/category/group/)
for i in range(10):
Projects
plt.scatter(i, i)
(https://block.arch.ethz.ch/blog/category/projects/)
plt.pause(0.5)
Research
this also works but only for scatter() (https://block.arch.ethz.ch/blog/category/research/)
Teaching
Reply (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/? (https://block.arch.ethz.ch/blog/category/teaching/)
replytocom=26635#respond) Tools
(https://block.arch.ethz.ch/blog/category/tools/)
Uncategorized
XMR (https://www.crypto-facile.fr/) says: December 25, 2017 at 10:06 am (https://block.arch.ethz.ch/blog/category/uncategorized
(https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/#comment-28933)
Reply (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/?
replytocom=28933#respond) Links
æ-lab (http://www.vub.ac.be/ARCH/ae-lab/)
BLOCK Research Group (http://block.arch.ethz.ch/)
2. Jan Wedekind (http://www.wedesoft.de/) says: November 27, 2017 at 4:25 pm
Computer Graphics and Geometry Laboratory
(https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/#comment-28496)
(http://lgg.epfl.ch)
I think it needs to be range instead of xrange.
eQUILIBRIUM
Also: Thanks a lot for posting this example! (http://block.arch.ethz.ch/equilibrium/)
Escobedo Construction
Reply (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/?
(http://escobedoconstruction.com/)
replytocom=28496#respond)
Form Finding Lab
(http://formfindinglab.princeton.edu/)
Interactive Geometry Lab (http://igl.ethz.ch/)
3. Edward Wong says: January 31, 2018 at 5:47 am
Masonry & Dynamics Research Group
(https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/#comment-29503)
(http://masonrydynamics.com/)
This post was very helpful! Is there a way I can plot 2 lines and animate them? Masonry at MIT (http://web.mit.edu/masonry/)
ODB Engineering (http://odb-engineering.com/)
Reply (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/?
Structural Design Lab
replytocom=29503#respond)
(http://web.mit.edu/structuraldesign/)
Reply (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/?
replytocom=30219#respond)
Reply (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/?
replytocom=32309#respond)
I’m looking for something similar. This is just plotting the plot with all x and y values from a txt file at
once. But it is not updating the values. I want something which draws (3,4) as an example, then
wait for 1 maybe 2 seconds, and then it should plot (3,4) and (2,3) as an example.
Reply (https://block.arch.ethz.ch/blog/2016/08/dynamic-plotting-with-matplotlib/?
replytocom=36632#respond)
Leave a response
Name (required)
Website
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote
cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Submit Comment
Copyright 2012 © BLOCK Research Group (http://block.arch.ethz.ch), ETH Zurich, Wolfgang-Pauli-Strasse 15, Log in (https://block.arch.ethz.ch/blog/wp-login.php)
8093 Zurich, Switzerland.
BRG blog is proudly powered by
WordPress (http://wordpress.org/), and built using the HTML5 Boilerplate (http://html5boilerplate.com/).