Mailing List Archive

matplotlib graph white space
I am using the first bar graph listed at this site:
https://matplotlib.org/stable/gallery/index.html

The problem I have is that there is too much white space around the graph.
My data would be better displayed if I could widen the graph into the space
to the right and left of the chart.

Steve

--
https://mail.python.org/mailman/listinfo/python-list
Re: matplotlib graph white space [ In reply to ]
In the plot window, you can click on the settings (up), and select the option "tight layout" by pressing that button... I think this is what you are looking for...


On 21/10/04 04:39AM, Steve wrote:
>
> I am using the first bar graph listed at this site:
> https://matplotlib.org/stable/gallery/index.html
>
> The problem I have is that there is too much white space around the graph.
> My data would be better displayed if I could widen the graph into the space
> to the right and left of the chart.
>
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list

--
Michel Alwan


( support Stallman : stallmansupport.org )
--
https://mail.python.org/mailman/listinfo/python-list
Re: matplotlib graph white space [ In reply to ]
> I am using the first bar graph listed at this site:
> https://matplotlib.org/stable/gallery/index.html
>
> The problem I have is that there is too much white space around the graph.
> My data would be better displayed if I could widen the graph into the space
> to the right and left of the chart.

It sounds like you're asking about changing the size and dimension of a
graph. Is that right?

Then I suggest looking into `figsize` when creating a figure (especially
if you are using the object oriented interface). Alternately, you can
adjust the size of a figure afterwards with `fig.set_size_inches` (and
variants), and you can get the figure if you are using the matlab-style
interface with `matplotlib.pyplot.gcf()`.

- DLD
--
https://mail.python.org/mailman/listinfo/python-list
RE: matplotlib graph white space [ In reply to ]
Yes, I saw that but it is a change for all sides.
Is there a setting to change just the left and right padding?




-----Original Message-----
From: Michel Alwan <michel@jagajaga.org>
Sent: Monday, October 4, 2021 7:56 AM
To: Steve <Gronicus@SGA.Ninja>
Cc: python-list@python.org
Subject: Re: matplotlib graph white space

In the plot window, you can click on the settings (up), and select the
option "tight layout" by pressing that button... I think this is what you
are looking for...


On 21/10/04 04:39AM, Steve wrote:
>
> I am using the first bar graph listed at this site:
> https://matplotlib.org/stable/gallery/index.html
>
> The problem I have is that there is too much white space around the graph.
> My data would be better displayed if I could widen the graph into the
> space to the right and left of the chart.
>
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list

--
Michel Alwan


( support Stallman : stallmansupport.org )

--
https://mail.python.org/mailman/listinfo/python-list
Re: matplotlib graph white space [ In reply to ]
u can adjust any side with the other options... (margins) if you don t want to use tight layout...
On 21/10/04 11:39AM, Steve wrote:
>
> Yes, I saw that but it is a change for all sides.
> Is there a setting to change just the left and right padding?
>
>
>
>
> -----Original Message-----
> From: Michel Alwan <michel@jagajaga.org>
> Sent: Monday, October 4, 2021 7:56 AM
> To: Steve <Gronicus@SGA.Ninja>
> Cc: python-list@python.org
> Subject: Re: matplotlib graph white space
>
> In the plot window, you can click on the settings (up), and select the
> option "tight layout" by pressing that button... I think this is what you
> are looking for...
>
>
> On 21/10/04 04:39AM, Steve wrote:
> >
> > I am using the first bar graph listed at this site:
> > https://matplotlib.org/stable/gallery/index.html
> >
> > The problem I have is that there is too much white space around the graph.
> > My data would be better displayed if I could widen the graph into the
> > space to the right and left of the chart.
> >
> > Steve
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
> --
> Michel Alwan
>
>
> ( support Stallman : stallmansupport.org )
>

--
Michel Alwan


( support Stallman : stallmansupport.org )
--
https://mail.python.org/mailman/listinfo/python-list
Re: matplotlib graph white space [ In reply to ]
On 04/10/2021 10:39, Steve wrote:
> I am using the first bar graph listed at this site:
> https://matplotlib.org/stable/gallery/index.html
>
> The problem I have is that there is too much white space around the graph.
> My data would be better displayed if I could widen the graph into the space
> to the right and left of the chart.
>
> Steve
>
To tweak the amount of padding around the matplotlib axes, you can use
pyplot.subplots_adjust [1] or Figure.subplots_adjust [2].

In most cases, the tight_layout function/method [3,4] will give you
sensible settings for the various spacing parameters.

You probably also have to adjust the figure size (see David Lowry-Duda's
reply) to get whatever effect it is that you want.

[1]
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplots_adjust.html
[2]
https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.subplots_adjust
[3]
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.tight_layout.html
[4]
https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.tight_layout

--
https://mail.python.org/mailman/listinfo/python-list