python


Matplotlib: multiprocess with joblib


I need to compute and then plot 18 figures, so I want to do multiprocess with Matplotlib (I use joblib here). Here is the example code:
def try_plot(y):
fig = plt.figure()
ax = fig.add_subplot(111)
x=arange(1,10)
ax.plot(x, x*y)
return fig
# This works
figs = [try_plot(y) for y in arange(3)]
# This fails
from joblib import Parallel, delayed
figs = Parallel(n_jobs=-1)(delayed(try_plot)(y) for y in arange(3))
The error it gives to me is this:
Exception in thread Thread-8:
Traceback (most recent call last):
File "D:\ProgramData\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "D:\ProgramData\Anaconda3\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 429, in _handle_results
task = get()
File "D:\ProgramData\Anaconda3\lib\multiprocessing\connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())
File "D:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py", line 1445, in __setstate__
mgr = plt._backend_mod.new_figure_manager_given_figure(num, self)
AttributeError: module 'ipykernel.pylab.backend_inline' has no attribute 'new_figure_manager_given_figure'
I searched around, but didn't find anyone use joblib with matplotlib, all I find is that it is possible to do multiprocessing with matplotlib, as stated in
https://matplotlib.org/2.0.0/examples/misc/multiprocess.html
Saving multiple matplotlib figures with multiprocessing

Related Links

Python: undo write to file
Python: “1-2-3-4” to [1, 2, 3, 4]
Problem sub-classing BaseException in Python
How can I render a tree structure (recursive) using a django template?
Is there a simple, elegant way to define singletons? [closed]
python cgi on IIS
Is it pythonic for a function to return multiple values?
Python dictionary from an object's fields
Python subprocess issue with ampersands
Directory listing in Python
SVG rendering in a PyGame application
Do you use the “global” statement in Python? [closed]
How do I successfully pass a function reference to Django’s reverse() function?
Python scope [duplicate]
Showing the stack trace from a running Python application
Building universal binaries on Mac - Forcing single compiler child process

Categories

HOME
sql-server
cluster-computing
jenkins-plugins
redis
json-ld
ruby-on-rails-3
apple-numbers
quill
dataframe
tumblr
docker-windows
internet-explorer-11
google-plus
xlsx
phoenix
cross-platform
movies
device-detection
marathon
statusbar
npm-install
novnc
samsung-mobile
shopping-cart
tampermonkey
ui5
metadata-extractor
xilinx-ise
cgal
i3
superscript
hibernate-cache
ioc-container
pari
modelandview
openpgp
powershell-remoting
passenger
pox
image-compression
freetts
concrete5-5.7
magiczoomplus
floating-accuracy
sendgrid-templates
jupyter-console
mediawiki-extensions
control-flow-graph
bing-translator-api
tiddlywiki
bnd
dwarf
chrome-remote-desktop
ticker
volume
etherpad
execl
adler32
qos
iron.io
hspec
push-diffusion
glkit
easing
pax-web
uiprogressview
spatial-query
gemini
django-south
asp.net-mvc-partialview
bluesnap
file-diffs
site-prism
selendroid
webhdfs
ffprobe
magento-1.12
moai
grunt-contrib-concat
cg
bullet
funkload
lumx
joox
resource-files
chrome-for-android
arangodb-php
sanitization
confusion-matrix
dwolla
mailcore
icsharpcode
tridion2009
continuous-testing
cross-domain-policy
mysql-error-1045
throttling
electronic-signature
newsstand-kit
printing-web-page
nvelocity
rijndael
email-spec
msn
unreachable-code
gwt-2.2-celltable
revision
ajaxpro

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App