rcfduarte / nmsat

Simulate and analyse complex microcircuits
GNU General Public License v2.0
6 stars 1 forks source link

colorbar error in plot_2d_parscans #30

Closed zbarni closed 7 years ago

zbarni commented 7 years ago

Lately these line in visualization.py if fig_handle is not None: cbar = fig_handle.colorbar(plt1, cax=cax)

cause the display of harvest to fail with error (if I only use savefig and don't display the image):

Traceback (most recent call last): File "noise_driven_dynamics_singletrial.py", line 143, in fig1.savefig("regularity.pdf") File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1565, in savefig self.canvas.print_figure(args, kwargs) File "/usr/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 2180, in print_figure kwargs) File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 2536, in print_pdf self.figure.draw(renderer) File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper draw(artist, renderer, args, kwargs) File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1159, in draw func(args) File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper draw(artist, renderer, args, kwargs) File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 2324, in draw a.draw(renderer) File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 61, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 1108, in draw renderer) File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 1061, in _get_tick_bboxes extent = tick.label2.get_window_extent(renderer) File "/usr/lib/python2.7/dist-packages/matplotlib/text.py", line 961, in get_window_extent bbox, info, descent = self._get_layout(self._renderer) File "/usr/lib/python2.7/dist-packages/matplotlib/text.py", line 361, in _get_layout ismath=ismath) File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 2086, in get_text_width_height_descent renderer=self) File "/usr/lib/python2.7/dist-packages/matplotlib/texmanager.py", line 678, in get_text_width_height_descent page = next(iter(dvi)) File "/usr/lib/python2.7/dist-packages/matplotlib/dviread.py", line 89, in iter have_page = self._read() File "/usr/lib/python2.7/dist-packages/matplotlib/dviread.py", line 149, in _read byte = ord(self.file.read(1)[0]) IndexError: string index out of range

If pl.show(block=False) is also used, the error is even more cryptic. Maybe this has to do with recent updates in matplotlib.rc? Do you encounter this as well? If the colorbar lines are removed, everything works fine, besides the colorbar not being displayed correctly..

zbarni commented 7 years ago

also happens with this:

pl_props = {
             'xlabel': pars.parameter_axes['ylabel'],
                         'ylabel': pars.parameter_axes['xlabel'],
                         'xticklabels': pars.parameter_axes['yticklabels'][::6],
                         'yticklabels': pars.parameter_axes['xticklabels'][::2],
                         'xticks': np.arange(0., len(pars.parameter_axes['yticks']), 6.),
                         'yticks': np.arange(0., len(pars.parameter_axes['xticks']), 2.),
    }

but not without the yticks...

pl_props = {
             'xlabel': pars.parameter_axes['ylabel'],
                         'ylabel': pars.parameter_axes['xlabel'],
                         'xticklabels': pars.parameter_axes['yticklabels'][::6],
                         'yticklabels': pars.parameter_axes['xticklabels'][::2],
                         'xticks': np.arange(0., len(pars.parameter_axes['yticks']), 6.),
                        #'yticks': np.arange(0., len(pars.parameter_axes['xticks']), 2.),
    }

Same error message..

rcfduarte commented 7 years ago

I use the plot_2d_parscan frequently and never encountered this error... The error message is very cryptic, so I don't know what causes it.. I also typically just display the figure and save them using the plot interface.. I will test runing the function with save only..

Make sure the pl_props are all consistent (they appear to be...)

zbarni commented 7 years ago

don't waste time on it if you haven't encountered it these days plot_2d_parscan is still working for you.. I think something's wrong on my computer, but will test it more..

rcfduarte commented 7 years ago

I just ran "/projects/encoding_decoding/read_data/noise_driven_dynamics_trialaverage.py", which uses this function 7 times and it worked without any problems.. Maybe check out how these functions are used there, maybe there's something different.. Try updating matplotlib as well (although I doubt it that this would be the cause, since I used this function a lot with a much older version and now with the latest and never got this error)...

zbarni commented 7 years ago

Thanks, will dig further.. closed.