This _must_ be a bug. Consider the following:
##############
import matplotlib
No it is not a bug -- mpl is doing what you tell it to do. Consider
>>> figure()
>>> subplot(111)
>>> plot([1,2,3])
>>> xlabel('hi mom', fontsize=100)
Each command has precise meaning -- the fig creates a figure using the
default size, the subplot occupies a fraction of that figure according
to the default ratios in the subplots_adjust parameters, and the
xlabel makes a label at an indicated physical size. You may not be
explicitly setting those sizes, but they are all defined via defaults
in the matplotlibrc. We try and make mpl do what you tell it to do,
not to try and out-smart you and do what we think you are telling it
to do.
Now I definitely support the idea that we should have a *feature* to
auto-adjust the subplots_adjust params and fontsizes so that it "just
works" more often. But this should be an optional feature so the user
who wants to express their intent clearly will not constantly be
stymied by mpl adjusting the sizes. Michael Droettboom has worked on
it and it is a difficult problem to get right.
JDH
···
On Wed, Jun 10, 2009 at 1:58 AM, Paul Anton Letnes<paul.anton.letnes@...287...> wrote:
Hm, I see. Thanks for an informative answer. I'll dig into my rcParams and matplotlibrc then...
Best regards,
Paul.
···
On 10. juni. 2009, at 14.53, John Hunter wrote:
On Wed, Jun 10, 2009 at 1:58 AM, Paul Anton > Letnes<paul.anton.letnes@...287...> wrote:
This _must_ be a bug. Consider the following:
##############
import matplotlib
No it is not a bug -- mpl is doing what you tell it to do. Consider
figure()
subplot(111)
plot([1,2,3])
xlabel('hi mom', fontsize=100)
Each command has precise meaning -- the fig creates a figure using the
default size, the subplot occupies a fraction of that figure according
to the default ratios in the subplots_adjust parameters, and the
xlabel makes a label at an indicated physical size. You may not be
explicitly setting those sizes, but they are all defined via defaults
in the matplotlibrc. We try and make mpl do what you tell it to do,
not to try and out-smart you and do what we think you are telling it
to do.
Now I definitely support the idea that we should have a *feature* to
auto-adjust the subplots_adjust params and fontsizes so that it "just
works" more often. But this should be an optional feature so the user
who wants to express their intent clearly will not constantly be
stymied by mpl adjusting the sizes. Michael Droettboom has worked on
it and it is a difficult problem to get right.
JDH
That is worth doing, but you needn't change the defaults. You can
also pass in the arguments explicitly:
fig = plt.figure((3,3))
fig.subplots_adjust(left=0.2, bottom=0.2)
ax = fig.add_subplot(111)
ax.plot(something)
ax.set_xlabel('test', fontsize=10)
for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_fontsize(8)
plt.show()
If you do want to change the defaults via matplotlibrc, though,
something to bear in mind is that you can have "per-directory" rc
files. So for example if you want your defaults to be changed for a
figures for publication, you can drop an rc file into the scripts
directory for that publication, and that will be used for that
directory only and will not affect the global defaults in
~/.matplotlib/matplotlibrc.
See http://matplotlib.sourceforge.net/users/customizing.html
JDH
···
On Wed, Jun 10, 2009 at 9:40 AM, Paul Anton Letnes<paul.anton.letnes@...287...> wrote:
Hm, I see. Thanks for an informative answer. I'll dig into my rcParams
and matplotlibrc then...
I don't mean to bother people with this question again, but has anyone implemented this auto-adjust feature that John was talking about? It would be nice not having to adjust matplotlib.rcParams['figure.subplot.left'] (and friends) in every plot script, or alternatively, through a clever hierarchy of matplotlibrc files.
By the way: kudos to matplotlib in every other respect!
Cheers
Paul
···
On 10. juni 2009, at 14.53, John Hunter wrote:
On Wed, Jun 10, 2009 at 1:58 AM, Paul Anton > Letnes<paul.anton.letnes@...287...> wrote:
This _must_ be a bug. Consider the following:
##############
import matplotlib
No it is not a bug -- mpl is doing what you tell it to do. Consider
figure()
subplot(111)
plot([1,2,3])
xlabel('hi mom', fontsize=100)
Each command has precise meaning -- the fig creates a figure using the
default size, the subplot occupies a fraction of that figure according
to the default ratios in the subplots_adjust parameters, and the
xlabel makes a label at an indicated physical size. You may not be
explicitly setting those sizes, but they are all defined via defaults
in the matplotlibrc. We try and make mpl do what you tell it to do,
not to try and out-smart you and do what we think you are telling it
to do.
Now I definitely support the idea that we should have a *feature* to
auto-adjust the subplots_adjust params and fontsizes so that it "just
works" more often. But this should be an optional feature so the user
who wants to express their intent clearly will not constantly be
stymied by mpl adjusting the sizes. Michael Droettboom has worked on
it and it is a difficult problem to get right.
JDH
Hi, I’d very much vote for such a feature, too. It’s absolutely not foolproof currently the way it is
What I find weird, too, is that while everthing fits on the canvas for PDF output, the left side is cropped for PNG.
´
Best regards,
Daniel
2011/2/1 Paul Anton Letnes wrote:
···
On 10. juni 2009, at 14.53, John Hunter wrote:
On Wed, Jun 10, 2009 at 1:58 AM, Paul Anton > > > > Letnes wrote:
This must be a bug. Consider the following:
##############
import matplotlib
No it is not a bug – mpl is doing what you tell it to do. Consider
figure()
subplot(111)
plot([1,2,3])
xlabel(‘hi mom’, fontsize=100)
Each command has precise meaning – the fig creates a figure using the
default size, the subplot occupies a fraction of that figure according
to the default ratios in the subplots_adjust parameters, and the
xlabel makes a label at an indicated physical size. You may not be
explicitly setting those sizes, but they are all defined via defaults
in the matplotlibrc. We try and make mpl do what you tell it to do,
not to try and out-smart you and do what we think you are telling it
to do.
Now I definitely support the idea that we should have a feature to
auto-adjust the subplots_adjust params and fontsizes so that it “just
works” more often. But this should be an optional feature so the user
who wants to express their intent clearly will not constantly be
stymied by mpl adjusting the sizes. Michael Droettboom has worked on
it and it is a difficult problem to get right.
JDH
I don’t mean to bother people with this question again, but has anyone implemented this auto-adjust feature that John was talking about? It would be nice not having to adjust matplotlib.rcParams[‘figure.subplot.left’] (and friends) in every plot script, or alternatively, through a clever hierarchy of matplotlibrc files.
By the way: kudos to matplotlib in every other respect!
Cheers
Paul