# workaround for graphics_array needing prior show?

I'm trying to use graphics_array to show a list of four simple plots. when I create the plots and display them straightaway in the graphics_array() it messes up the axis labeling and so on. I discovered via google that you can workaround that by first calling show() or save() on each of the graphs (I guess that finalizes their layout etc), and then call graphics array to combine them. But this results in each of the charts being shown individually before being shown in an array, which defeats the purpose.

The closest I've found is calling save('foo.pdf') on each of the charts, since it doesn't know how to display a PDF file you only get a link to 'foo.pdf'. I guess what I'd really like is save(filename, display=False) or something? (Of course ultimately I'd like graphics_array() to do the right thing in the first place and prepare each chart individually before compositing them)

Any ideas?

edit retag close merge delete

Sort by » oldest newest most voted

I presume you are working on the notebook interface. You can do save('file.png') and it will show you the figure. You can also do save('/tmp/file.png') and it will not show you the figure since the figure is saved in a different path (provided you have write access to that path).

more

The save('/tmp/file.png') works perfectly, though I'm not sure I understand why it displays the first case but not the second (when it obviously can 'see' both files since it wrote them) - what logic does it use to decide whether to show it or not? I will have to take a look at the code.

( 2012-11-30 15:54:23 +0200 )edit

Any image file that is saved in the current directory (in which the cell is evaluated) is displayed automatically by the notebook interface. There is code which takes care of this. If you save it in a different path, then the file won't show up since it is not in the current directory.

( 2012-11-30 22:36:25 +0200 )edit