[IPython-dev] Notebook: Horizontal layout for multiple figures in output cell

Antonino Ingargiola tritemio at gmail.com
Fri Feb 21 14:54:50 EST 2014

Looking at the HTML structure I found that the output cell is inside a <div
class="output_vbox"> containing one or more  <div class="output_area"> that
are vertically stacked. With two plots we have 3 "output_area": the first
for the text output (Out[1] ...) and the other two for the two figures.

The problem in changing the style of <div class="output_vbox"> to
horizontal is that also the text-only div will be stacked horizontally,
shifting the figures to the right. Probably this is why Jon had right
aligned figures.

Ideally the output text should stay unchanged and the figures stacked
horizontally just below the text, with a left alignment.

Any idea on how to achieve this appreciated.


On Fri, Feb 21, 2014 at 10:49 AM, Jon Wilson <jsw at fnal.gov> wrote:

>  I often have the same desire as Antonino, for much the same reasons.
> Creating subplots is really not an appropriate solution.  The separate
> figures are exactly that, separate figures.  It is semantically incorrect
> to combine them into one figure, and causes additional complications when I
> want to save them to a file (for example if I want to include them in a
> manuscript) -- if I have combined them as subplots, then when I want to
> save them, I must re-separate them.
> Antonino, at one point, with a much older (pre 1.0) version of the
> notebook, I found a way to hack the notebook CSS so that output cells would
> float left.  This was a (nearly) perfect solution for me.  However, I
> suspect it might not work anymore with newer versions of the notebook.
> When I updated to a post 1.0 version, I never took the time to get it
> working again.  But perhaps that idea is a starting point for you.  Take a
> look at the HTML structure of the notebook and output cells, and then
> fiddle with the CSS (in whatever way is now appropriate) until you get
> something that works better for you.
> Regards,
> Jon
> On 02/21/2014 12:13 PM, Patrick Surry wrote:
>  If you're using matplotlib for your plots, you can use subplots to
> create a horizontal (or arbitrary grid) of plots in an output cell.
>  Try this example
> http://matplotlib.org/examples/pylab_examples/subplot_demo.html
>  but change plt.subplot(2,1,1) and plt.subplot(2,1,2) (which indicate a
> 2x1 grid and plot #1 and #2) to plt.subplot(1,2,1) and plt.subplot(1,2,2)
> which does the same in a 1x2 grid.
> _______________________________________________
> IPython-dev mailing listIPython-dev at scipy.orghttp://mail.scipy.org/mailman/listinfo/ipython-dev
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140221/f8ab0e7f/attachment.html>

More information about the IPython-dev mailing list