-
Notifications
You must be signed in to change notification settings - Fork 0
Archive Trac docs matplotlib
madscatt edited this page Jun 20, 2026
·
1 revision
Legacy Trac archive page imported from
docs_matplotlib. Source: https://genapp.rocks/wiki/wiki/docs_matplotlib. Review age, links, and examples before treating as current.
- tmp/pythonlib/
- genapp.py / starting library for genapp python
- ga_webagg.py / plot example
- port pool notes
- figure out
- how to turn the embedding_webagg into streaming
- is it possible?
- doesn't seem to work, simply using webagg directly does
- what can we do with plot objects
- save/restore?
- change dynamically?
- https://stackoverflow.com/questions/10944621/dynamically-updating-plot-in-matplotlib
- animation works for basic webagg but not under embedding
import numpy as np
import matplotlib
print matplotlib.rcParams
matplotlib.use('webagg')
import matplotlib.pyplot as plt
import matplotlib.animation as animation
def update_line(num, data, line):
print "update_line"
line.set_data(data[..., :num])
return line,
def myplotshow():
matplotlib.rcParams['webagg.open_in_browser'] = False
matplotlib.rcParams['webagg.address'] = "0.0.0.0"
matplotlib.rcParams['webagg.port'] = 8080
plt.show()
print "create figure"
fig1 = plt.figure()
data = np.random.rand(2, 25)
l, = plt.plot([], [], 'r-')
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.xlabel('x')
plt.title('test')
line_ani = animation.FuncAnimation(fig1, update_line, 25, fargs=(data, l),
interval=200, blit=True)
myplotshow();
-
alternative?
- use genapp
- genapp sets up servers as needed
- provides python library for setup of tcp, updating plots
-
using mpl.use('webagg')
- global port range in appconfig?
- genapp type "matplotlib'
- assign a port from global pool for each jobs mpl plots
- php routines to assign ports
- mongo'd globally with timestamp, job info
- scanner daemon to "clean up" or simply report status
- setup iframe in type frag with responsive css
- tcp server required
- python library
- ga_keepalive( jsoninput )
- interval timer to message i still want my ports for plots
- see 2nd answer here https://stackoverflow.com/questions/3393612/run-certain-code-every-n-seconds
- ga_plot_show( jsoninput, id )
- messages UI that input is ready
- installs exit handler to pickle plot https://docs.python.org/2/library/atexit.html
- to allow reattach
- reattach
- get saved plot info, restart simple show'r from pickles
- example https://matplotlib.org/examples/user_interfaces/embedding_webagg.html gets confused when hit by multiple servers
- so does simple webagg
- discussion https://github.com/matplotlib/matplotlib/issues/2620/
- multiplexing servers
- e.g. some sites only allow 443
- ssh
- probably need to create our own backend as a copy of matplotlib/backends/backend_webagg.py
- wss option?
- ssl option
- max websockets
- https://stackoverflow.com/questions/26003756/is-there-a-limit-practical-or-otherwise-to-the-number-of-web-sockets-a-page-op/26013035
- basic test
- iframe matplotlib element
- genapp python caller
- python side
- returns uuid for figure, initializes the handler, runs a local server
- sets up a webpage
- genapp server daemon that knows about this and routes calls to the python side
- multiplexd over regular ws?
- e.g.
- user's python is running the server
- genapp handles getting it to the UI
- reattachment issue
- reattaching after the job has run would somehow need to restart the servers
- perhaps a hook could be registered in the genapp python caller for the final plot at end?
- serves websocket and http(s) over single port
- works in iframes, responsive example:
<html>
<style>
.iframe-container {
overflow: hidden;
padding-top: 56.25%;
position: relative;
}
.iframe-container iframe {
border: 0;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
</style>
<body>
Test for matplotlib embedded in iframe
<body>
<div class="iframe-container">
<iframe frameBorder=0 src=http://129.114.104.249:8080>iframe tag text</iframe>
</div>
</html>
- needs Agg for no X, so before import or from matplotlib
import matplotlib as mpl
mpl.use('Agg')