Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug version 0.23.1? #47

Closed
MCostanzi opened this issue Dec 11, 2017 · 9 comments
Closed

bug version 0.23.1? #47

MCostanzi opened this issue Dec 11, 2017 · 9 comments

Comments

@MCostanzi
Copy link

Hi,

I've update chainConsumer to the latest version (0.23.1) and I'm having problem with the Plotter.plot() class (with the version 0.21.7 I I didn't experience this problem).
For instance, if I try to run the example "plot_introduction.ipynb" I get the following error:

`---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.pyc in __call__(self, obj)
    335                 pass
    336             else:
--> 337                 return printer(obj)
    338             # Finally look for special method names
    339             method = _safe_get_formatter_method(obj, self.print_method)

/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
    205 
    206     if 'png' in formats:
--> 207         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    208     if 'retina' in formats or 'png2x' in formats:
    209         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
    115 
    116     bytes_io = BytesIO()
--> 117     fig.canvas.print_figure(bytes_io, **kw)
    118     data = bytes_io.getvalue()
    119     if fmt == 'svg':

/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2257                 orientation=orientation,
   2258                 bbox_inches_restore=_bbox_inches_restore,
-> 2259                 **kwargs)
   2260         finally:
   2261             if bbox_inches and restore_bbox:

/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    505 
    506     def print_png(self, filename_or_obj, *args, **kwargs):
--> 507         FigureCanvasAgg.draw(self)
    508         renderer = self.get_renderer()
    509         original_dpi = renderer.dpi

/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    428             if toolbar:
    429                 toolbar.set_cursor(cursors.WAIT)
--> 430             self.figure.draw(self.renderer)
    431         finally:
    432             if toolbar:

/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     53                 renderer.start_filter()
     54 
---> 55             return draw(artist, renderer, *args, **kwargs)
     56         finally:
     57             if artist.get_agg_filter() is not None:

/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in draw(self, renderer)
   1293 
   1294             mimage._draw_list_compositing_images(
-> 1295                 renderer, self, artists, self.suppressComposite)
   1296 
   1297             renderer.close_group('figure')

/usr/local/lib/python2.7/dist-packages/matplotlib/image.pyc in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    136     if not_composite or not has_images:
    137         for a in artists:
--> 138             a.draw(renderer)
    139     else:
    140         # Composite any adjacent images together

/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     53                 renderer.start_filter()
     54 
---> 55             return draw(artist, renderer, *args, **kwargs)
     56         finally:
     57             if artist.get_agg_filter() is not None:

/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2397             renderer.stop_rasterizing()
   2398 
-> 2399         mimage._draw_list_compositing_images(renderer, self, artists)
   2400 
   2401         renderer.close_group('axes')

/usr/local/lib/python2.7/dist-packages/matplotlib/image.pyc in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    136     if not_composite or not has_images:
    137         for a in artists:
--> 138             a.draw(renderer)
    139     else:
    140         # Composite any adjacent images together

/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     53                 renderer.start_filter()
     54 
---> 55             return draw(artist, renderer, *args, **kwargs)
     56         finally:
     57             if artist.get_agg_filter() is not None:

/usr/local/lib/python2.7/dist-packages/matplotlib/axis.pyc in draw(self, renderer, *args, **kwargs)
   1145         self._update_label_position(ticklabelBoxes, ticklabelBoxes2)
   1146 
-> 1147         self.label.draw(renderer)
   1148 
   1149         self._update_offset_text_position(ticklabelBoxes, ticklabelBoxes2)

/usr/local/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     53                 renderer.start_filter()
     54 
---> 55             return draw(artist, renderer, *args, **kwargs)
     56         finally:
     57             if artist.get_agg_filter() is not None:

/usr/local/lib/python2.7/dist-packages/matplotlib/text.pyc in draw(self, renderer)
    761             posy = float(textobj.convert_yunits(textobj._y))
    762             if not np.isfinite(posx) or not np.isfinite(posy):
--> 763                 raise ValueError("posx and posy should be finite values")
    764             posx, posy = trans.transform_point((posx, posy))
    765             canvasw, canvash = renderer.get_canvas_width_height()

ValueError: posx and posy should be finite values
`

The new class "plotter.plot_summary" works very nicely instead :)
Do you have any suggestion on how to fix this error?

Thanks a lot.

Matteo

@Samreay
Copy link
Owner

Samreay commented Dec 11, 2017

Hi Matteo,

That is an interesting issue, I have no idea why that is happening, especially if the other plot method is working. If you are able to zip up the example and chains I can test on my machine and see if there are any issues that jump out.

The posx and poxy issues Ive seen before from having NaNs or infs in the chains, but those issues are easy to find in the stacktrace because its normally the trace points to the histogram. Here I am actually very much confused, because from what I can see chainconsumer doesn't appear in the stacktrace at all!

@MCostanzi
Copy link
Author

MCostanzi commented Dec 11, 2017

Hi,
thanks a lot for the quick reply.
Acatully, since I wanted to be sure that it was not a problem of my chains I used your example "plot_introduction.ipynb" to test it. So the code I'm using for the test is:

np.random.seed(0)
data = np.random.multivariate_normal([0.0, 4.0], [[1.0, 0.7], [0.7, 1.5]], size=10000)

c = ChainConsumer()
c.add_chain(data, parameters=["$x_1$", "$x_2$"])
fig = c.plotter.plot(figsize="column", truth=[0.0, 4.0])

(I've explicitly checked that there are no Nans in the data. Moreover, other library such as "corner" works with the same data vector)

@Samreay
Copy link
Owner

Samreay commented Dec 11, 2017

How odd, that code definitely works, so Im wondering if it is an issue with the environment (ah yes, now I see your original sentence highlighting it was an intro example!)

Can you confirm that you get the same error if you download the pure python code and run it, or if it only happens with the ipython environment?

@MCostanzi
Copy link
Author

MCostanzi commented Dec 11, 2017

Mmm, interesting.
So I tried to use the pure python code.
If I just ask to display the plot, i.e.:

fig = c.plotter.plot(display=True, figsize="column", truth=[0.0, 4.0])

I have no problem

If instead I try to save it:

fig = c.plotter.plot(filename="/home/costanzi/Desktop/test.png", figsize="column", truth=[0.0, 4.0])

I got the same error.

@Samreay
Copy link
Owner

Samreay commented Dec 11, 2017 via email

@MCostanzi
Copy link
Author

I see, I'll try to do these updates.

Thanks a lot!

@Samreay
Copy link
Owner

Samreay commented Dec 12, 2017

Seems like there is a bug in the latest version of matplotlib which is affecting many users. Ive updated CC to force a good matplotlib version, so please update cc and hopefully all the posx posy issues will disappear and youll be able to save figures again.

@MCostanzi
Copy link
Author

Great, it works again now! Thanks a lot :)

@Samreay Samreay closed this as completed Dec 12, 2017
@Samreay
Copy link
Owner

Samreay commented Dec 12, 2017

Glad it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants