Problem plotting HDDMRegressor outputs

142 views
Skip to first unread message

Jim Cavanagh

unread,
Jun 24, 2016, 12:51:52 PM6/24/16
to hddm-users
I'm running ipython notebook on a PC.  This may be a python (not HDDM) issue, but I've tried everything I can think of, and after they both didn't work, I was out of things to think of.

I can't plot or save images from HDDMRegressor outputs.  Which is odd, since the a, t, v etc plots print out, but the regressors won't (which HDDM itself labeled).   


----------------------------------------------------------------------------------------------------------------------
label='v'
model_v=hddm.models.HDDMRegressor(data, ['v ~ PE:C(FB)'], p_outlier=.05);
model_v.sample(ITER, burn=BURN, dbname='v.db', db='pickle')
model_v.save(label)
textname=label+'.txt'
model_v.plot_posteriors(save=True)
model_v.print_stats(fname=textname)


Adding these covariates:
['v_Intercept', 'v_PE:C(FB)[Pun]', 'v_PE:C(FB)[Rew]']
 [-----------------100%-----------------] 501 of 500 complete in 148.6 secWARNING: Will not save custom link functions.
Plotting a
Plotting a_std
Plotting t
Plotting t_std
Plotting v
Plotting v_std
Plotting v_PE:C(FB)[Pun]
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-9-3a95050f70fb> in <module>()
      4 model_v.save(label)
      5 textname=label+'.txt'
----> 6 model_v.plot_posteriors(save=True)
      7 model_v.print_stats(fname=textname)

etc etc...

C:\Users\James Cavanagh\Anaconda\lib\site-packages\matplotlib\backends\backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    508         renderer.dpi = self.figure.dpi
    509         if is_string_like(filename_or_obj):
--> 510             filename_or_obj = open(filename_or_obj, 'wb')
    511             close = True
    512         else:

IOError: [Errno 2] No such file or directory: './v_PE:C(FB)[Pun].png

--------------------------------------------  Nor will this little tidbit work:

plot.plot_posterior_nodes(model_v.nodes_db[model_v.nodes_db.knode_name == 'v_PE:C(FB)[Pun]']['node'], lb= -.5, ub=.5)
pl.savefig(join('v_PE:C(FB)[Pun].pdf')) 




Thomas Wiecki

unread,
Jun 24, 2016, 5:35:28 PM6/24/16
to hddm-...@googlegroups.com
Hi Jim,

I think windows can't handle that filename.You could instead save the plots manually when they display under a different name.

Best,
Thomas

--
You received this message because you are subscribed to the Google Groups "hddm-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hddm-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jim Cavanagh

unread,
Jun 25, 2016, 9:15:05 AM6/25/16
to hddm-users
That's the sticky wicket - nothing will display.  Not even the a,v,t plots.

I tried this in iPython (not notebook) as well - no luck.  

Surely someone else running Windows has experienced this before ...?

J

Thomas Wiecki

unread,
Jun 25, 2016, 9:30:57 AM6/25/16
to hddm-...@googlegroups.com
Why not use the notebook? If you do, make sure to run a cell with "%matplotlib inline" at the top.
Reply all
Reply to author
Forward
0 new messages