Ask Your Question
0

workaround for graphics_array needing prior show?

asked 2012-11-30 13:52:41 +0100

PatrickSurry gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-11-30 14:47:31 +0100

ppurka gravatar image

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).

edit flag offensive delete link more

Comments

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.

PatrickSurry gravatar imagePatrickSurry ( 2012-11-30 15:54:23 +0100 )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.

ppurka gravatar imageppurka ( 2012-11-30 22:36:25 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-11-30 13:52:41 +0100

Seen: 366 times

Last updated: Nov 30 '12