Hints on sizing plot elements?

I'm making a strip chart widget (which I plan to make publicly available
when finished). The basics are working fine, but the automatic sizing is
not doing so well. Strip charts are typically short, and when suitably
short the X axis annotations are partially truncated.

So...can I convince the automatic sizer to always show the full X (time)
axis annotations and put all the variable sizing into the data area? Or
do I have to manually set them somehow?

Also, is there a way from my software (not a .matplotlibrc file) to
globally make the default background color white for axis annotation
areas? Right now the background is gray for annotations and while for
plot area and I'd prefer it was all white.

-- Russell

I'm making a strip chart widget (which I plan to make publicly available
when finished). The basics are working fine, but the automatic sizing is
not doing so well. Strip charts are typically short, and when suitably
short the X axis annotations are partially truncated.

So...can I convince the automatic sizer to always show the full X (time)
axis annotations and put all the variable sizing into the data area? Or
do I have to manually set them somehow?

As far as I know, there's nothing to automatically resize the padding around the the axes. (The manual way to do it is to call `fig.subplots_adjust`). I wrote a helper script (attached below) to adjust the layout so that there's a specified amount of padding around the axes.

Unfortunately, this resizer doesn't function correctly when using the GTK backend. It apparently works fine with TkAgg, MacOSX, and Qt4Agg backends.

Also, is there a way from my software (not a .matplotlibrc file) to
globally make the default background color white for axis annotation
areas? Right now the background is gray for annotations and while for
plot area and I'd prefer it was all white.

-- Russell

Just set plt.rc('figure', facecolor='w') in your code (assuming you've imported matplotlib.pyplot as plt).

Best,
-Tony

tight_layout.py (5.88 KB)

···

On Aug 12, 2010, at 1:08 AM, Russell E. Owen wrote:

I’m making a strip chart widget (which I plan to make publicly available
when finished). The basics are working fine, but the automatic sizing is
not doing so well. Strip charts are typically short, and when suitably
short the X axis annotations are partially truncated.

So…can I convince the automatic sizer to always show the full X (time)
axis annotations and put all the variable sizing into the data area? Or
do I have to manually set them somehow?

As far as I know, there’s nothing to automatically resize the padding around the the axes. (The manual way to do it is to call fig.subplots_adjust). I wrote a helper script (attached below) to adjust the layout so that there’s a specified amount of padding around the axes.

Unfortunately, this resizer doesn’t function correctly when using the GTK backend. It apparently works fine with TkAgg, MacOSX, and Qt4Agg backends.

Fortunately I’m using TkAgg. I’m sorry (though not surprised) I’ll have to size it manually (especially since users of my application can change the font size), but I very much appreciate the code.

Also, is there a way from my software (not a .matplotlibrc file) to

globally make the default background color white for axis annotation
areas? Right now the background is gray for annotations and while for
plot area and I’d prefer it was all white.

Just set plt.rc(‘figure’, facecolor=‘w’) in your code (assuming you’ve imported matplotlib.pyplot as plt).

Perfect. Thanks!

<tight_layout.py>

Usage note: Since it sounds like you’re not creating subplots, you can just use the tight_borders function, instead of the tight_layout function; the later requires two redraws while the first requires only one.

Thank you very much for the advice and script!

I do plan to support strip charts stacked atop each other (all using the same time range, with tick labels only along the bottom x axis), which I suspect will need subplots (unless there is now a better way) but so far all I have is multiple lines (including dynamic and static – e.g. to display limits) one one plot.

– Russell

···

On Aug 12, 2010, at 7:37 AM, Tony S Yu wrote:

On Aug 12, 2010, at 1:08 AM, Russell E. Owen wrote:

Another option you may try is to use axes_grid1 toolkit.
Attached is a simplified version of the script I have been using.
matplotlib v1.0 is required.

IHTH,

-JJ

make_room_for_ylabel_using_axesgrid.py (1.11 KB)

···

On Thu, Aug 12, 2010 at 2:08 PM, Russell E. Owen <rowen@...2756...> wrote:

So...can I convince the automatic sizer to always show the full X (time)
axis annotations and put all the variable sizing into the data area? Or
do I have to manually set them somehow?