|
From: Arne.Bittig <arn...@in...> - 2006-04-06 12:14:57
|
Hi, I am using matplotlib to draw graphs. When I try to save a picture (using savefig; usually as png, but at some point I might need eps files as well), the actual graph comprises less than the central 50% of the image, the rest of the image is wasted space. I already tried figure(frameon = False, facecolor = 'w') and box(False) to get rid of the redundant frame, but apparently it did not help (apart from removing the black frame, obviously, but what I want is to save only what is inside this frame). Any ideas how to do this? If not, does anyone know a python tool that handles pngs and would enable me to crop the picture in a second step? Arne |
|
From: Ryan K. <rya...@gm...> - 2006-04-06 12:24:14
Attachments:
test.png
|
I don't think this is the default behavior. If I do
t=3Darange(0,1,0.01)
y=3Dsin(2*pi*t)
plot(t,y)
xlabel('Time (sec)')
ylabel('Amplitude')
savefig('test.png')
I get the attached png without the extra border you describe.
Ryan
On 4/6/06, Arne.Bittig <arn...@in...> wrote:
> Hi,
>
> I am using matplotlib to draw graphs. When I try to save a picture
> (using savefig; usually as png, but at some point I might need eps files
> as well), the actual graph comprises less than the central 50% of the
> image, the rest of the image is wasted space.
>
> I already tried figure(frameon =3D False, facecolor =3D 'w') and box(Fals=
e)
> to get rid of the redundant frame, but apparently it did not help (apart
> from removing the black frame, obviously, but what I want is to save
> only what is inside this frame).
>
> Any ideas how to do this? If not, does anyone know a python tool that
> handles pngs and would enable me to crop the picture in a second step?
>
> Arne
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting langua=
ge
> that extends applications into web and mobile media. Attend the live webc=
ast
> and join the prime developer group breaking into this new coding territor=
y!
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
|
|
From: Arne.Bittig <arn...@in...> - 2006-04-06 12:37:16
|
Sorry, maybe I didn't make that clear enough.
I was talking about a graph as in "graph theory". Since there is no
meaningful way to label the axes, and, in fact, no reason to show them
at all, the white space I was talking about is just where in your
picture there are the labels. So, looking at your example, what I'd like
to have is what's inside the black rectangle, i.e. a png where the blue
curve touches the top and the bottom of the image.
Arne
Ryan Krauss wrote:
> I don't think this is the default behavior. If I do
>
> t=arange(0,1,0.01)
> y=sin(2*pi*t)
> plot(t,y)
> xlabel('Time (sec)')
> ylabel('Amplitude')
> savefig('test.png')
>
> I get the attached png without the extra border you describe.
>
> Ryan
>
>
> On 4/6/06, Arne.Bittig <arn...@in...> wrote:
>
>>Hi,
>>
>>I am using matplotlib to draw graphs. When I try to save a picture
>>(using savefig; usually as png, but at some point I might need eps files
>>as well), the actual graph comprises less than the central 50% of the
>>image, the rest of the image is wasted space.
>>
>>I already tried figure(frameon = False, facecolor = 'w') and box(False)
>>to get rid of the redundant frame, but apparently it did not help (apart
>>from removing the black frame, obviously, but what I want is to save
>>only what is inside this frame).
>>
>>Any ideas how to do this? If not, does anyone know a python tool that
>>handles pngs and would enable me to crop the picture in a second step?
>>
>>Arne
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by xPML, a groundbreaking scripting language
>>that extends applications into web and mobile media. Attend the live webcast
>>and join the prime developer group breaking into this new coding territory!
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>>_______________________________________________
>>Matplotlib-users mailing list
>>Mat...@li...
>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>>
>
>
> ------------------------------------------------------------------------
>
|
|
From: Michael V. De P. <mde...@ma...> - 2006-04-06 12:41:50
|
Arne, I don't know about the "real" solution to this problem, but if you want to go the route of "artificially" solving it with an image library for post processing, you can check out Python Imaging Library: http://www.pythonware.com/products/pil/ Mike On Thu, Apr 06, 2006 at 02:36:55PM +0200, Arne.Bittig wrote: > Sorry, maybe I didn't make that clear enough. > > I was talking about a graph as in "graph theory". Since there is no > meaningful way to label the axes, and, in fact, no reason to show them > at all, the white space I was talking about is just where in your > picture there are the labels. So, looking at your example, what I'd like > to have is what's inside the black rectangle, i.e. a png where the blue > curve touches the top and the bottom of the image. > > Arne > > Ryan Krauss wrote: > > >I don't think this is the default behavior. If I do > > > >t=arange(0,1,0.01) > >y=sin(2*pi*t) > >plot(t,y) > >xlabel('Time (sec)') > >ylabel('Amplitude') > >savefig('test.png') > > > >I get the attached png without the extra border you describe. > > > >Ryan > > > > > >On 4/6/06, Arne.Bittig <arn...@in...> wrote: > > > >>Hi, > >> > >>I am using matplotlib to draw graphs. When I try to save a picture > >>(using savefig; usually as png, but at some point I might need eps files > >>as well), the actual graph comprises less than the central 50% of the > >>image, the rest of the image is wasted space. > >> > >>I already tried figure(frameon = False, facecolor = 'w') and box(False) > >>to get rid of the redundant frame, but apparently it did not help (apart > >>from removing the black frame, obviously, but what I want is to save > >>only what is inside this frame). > >> > >>Any ideas how to do this? If not, does anyone know a python tool that > >>handles pngs and would enable me to crop the picture in a second step? > >> > >>Arne > >> > >> > >>------------------------------------------------------- > >>This SF.Net email is sponsored by xPML, a groundbreaking scripting > >>language > >>that extends applications into web and mobile media. Attend the live > >>webcast > >>and join the prime developer group breaking into this new coding > >>territory! > >>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > >>_______________________________________________ > >>Matplotlib-users mailing list > >>Mat...@li... > >>https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > >> > > > > > >------------------------------------------------------------------------ > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Ryan K. <rya...@gm...> - 2006-04-06 12:54:20
Attachments:
test.png
|
Not a problem. Go into your matplotlibrc file and change these lines: # The figure subplot parameters. All dimensions are fraction of the # figure width or height figure.subplot.left : 0.001 # the left side of the subplots of the figure figure.subplot.right : 0.999 # the right side of the subplots of the fig= ure figure.subplot.bottom : 0.001 # the bottom of the subplots of the figure figure.subplot.top : 0.999 figure.subplot.wspace : 0.001 # the amount of width reserved for blank space between subplots figure.subplot.hspace : 0.001 # the amount of height reserved for white space between subplots They control the white space around the frame where the axes go. With the above values, I created the attached plot which I think is close to what you want. Ryan On 4/6/06, Michael V. De Palatis <mde...@ma...> wrote: > Arne, > > I don't know about the "real" solution to this problem, but if you > want to go the route of "artificially" solving it with an image > library for post processing, you can check out Python Imaging Library: > > http://www.pythonware.com/products/pil/ > > Mike > > On Thu, Apr 06, 2006 at 02:36:55PM +0200, Arne.Bittig wrote: > > Sorry, maybe I didn't make that clear enough. > > > > I was talking about a graph as in "graph theory". Since there is no > > meaningful way to label the axes, and, in fact, no reason to show them > > at all, the white space I was talking about is just where in your > > picture there are the labels. So, looking at your example, what I'd lik= e > > to have is what's inside the black rectangle, i.e. a png where the blue > > curve touches the top and the bottom of the image. > > > > Arne > > > > Ryan Krauss wrote: > > > > >I don't think this is the default behavior. If I do > > > > > >t=3Darange(0,1,0.01) > > >y=3Dsin(2*pi*t) > > >plot(t,y) > > >xlabel('Time (sec)') > > >ylabel('Amplitude') > > >savefig('test.png') > > > > > >I get the attached png without the extra border you describe. > > > > > >Ryan > > > > > > > > >On 4/6/06, Arne.Bittig <arn...@in...> wrote: > > > > > >>Hi, > > >> > > >>I am using matplotlib to draw graphs. When I try to save a picture > > >>(using savefig; usually as png, but at some point I might need eps fi= les > > >>as well), the actual graph comprises less than the central 50% of the > > >>image, the rest of the image is wasted space. > > >> > > >>I already tried figure(frameon =3D False, facecolor =3D 'w') and box(= False) > > >>to get rid of the redundant frame, but apparently it did not help (ap= art > > >>from removing the black frame, obviously, but what I want is to save > > >>only what is inside this frame). > > >> > > >>Any ideas how to do this? If not, does anyone know a python tool that > > >>handles pngs and would enable me to crop the picture in a second step= ? > > >> > > >>Arne > > >> > > >> > > >>------------------------------------------------------- > > >>This SF.Net email is sponsored by xPML, a groundbreaking scripting > > >>language > > >>that extends applications into web and mobile media. Attend the live > > >>webcast > > >>and join the prime developer group breaking into this new coding > > >>territory! > > >>http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&d= at=3D121642 > > >>_______________________________________________ > > >>Matplotlib-users mailing list > > >>Mat...@li... > > >>https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > >> > > > > > > > > >----------------------------------------------------------------------= -- > > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a groundbreaking scripting > > language > > that extends applications into web and mobile media. Attend the live > > webcast > > and join the prime developer group breaking into this new coding > > territory! > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: Ryan K. <rya...@gm...> - 2006-04-06 12:57:30
|
My solution and Darren's do nearly the same thing. On 4/6/06, Ryan Krauss <rya...@gm...> wrote: > Not a problem. Go into your matplotlibrc file and change these lines: > > # The figure subplot parameters. All dimensions are fraction of the > # figure width or height > figure.subplot.left : 0.001 # the left side of the subplots of the figu= re > figure.subplot.right : 0.999 # the right side of the subplots of the f= igure > figure.subplot.bottom : 0.001 # the bottom of the subplots of the figur= e > figure.subplot.top : 0.999 > figure.subplot.wspace : 0.001 # the amount of width reserved for > blank space between subplots > figure.subplot.hspace : 0.001 # the amount of height reserved for > white space between subplots > > They control the white space around the frame where the axes go. With > the above values, I created the attached plot which I think is close > to what you want. > > Ryan > > On 4/6/06, Michael V. De Palatis <mde...@ma...> wrote: > > Arne, > > > > I don't know about the "real" solution to this problem, but if you > > want to go the route of "artificially" solving it with an image > > library for post processing, you can check out Python Imaging Library: > > > > http://www.pythonware.com/products/pil/ > > > > Mike > > > > On Thu, Apr 06, 2006 at 02:36:55PM +0200, Arne.Bittig wrote: > > > Sorry, maybe I didn't make that clear enough. > > > > > > I was talking about a graph as in "graph theory". Since there is no > > > meaningful way to label the axes, and, in fact, no reason to show the= m > > > at all, the white space I was talking about is just where in your > > > picture there are the labels. So, looking at your example, what I'd l= ike > > > to have is what's inside the black rectangle, i.e. a png where the bl= ue > > > curve touches the top and the bottom of the image. > > > > > > Arne > > > > > > Ryan Krauss wrote: > > > > > > >I don't think this is the default behavior. If I do > > > > > > > >t=3Darange(0,1,0.01) > > > >y=3Dsin(2*pi*t) > > > >plot(t,y) > > > >xlabel('Time (sec)') > > > >ylabel('Amplitude') > > > >savefig('test.png') > > > > > > > >I get the attached png without the extra border you describe. > > > > > > > >Ryan > > > > > > > > > > > >On 4/6/06, Arne.Bittig <arn...@in...> wrote= : > > > > > > > >>Hi, > > > >> > > > >>I am using matplotlib to draw graphs. When I try to save a picture > > > >>(using savefig; usually as png, but at some point I might need eps = files > > > >>as well), the actual graph comprises less than the central 50% of t= he > > > >>image, the rest of the image is wasted space. > > > >> > > > >>I already tried figure(frameon =3D False, facecolor =3D 'w') and bo= x(False) > > > >>to get rid of the redundant frame, but apparently it did not help (= apart > > > >>from removing the black frame, obviously, but what I want is to sav= e > > > >>only what is inside this frame). > > > >> > > > >>Any ideas how to do this? If not, does anyone know a python tool th= at > > > >>handles pngs and would enable me to crop the picture in a second st= ep? > > > >> > > > >>Arne > > > >> > > > >> > > > >>------------------------------------------------------- > > > >>This SF.Net email is sponsored by xPML, a groundbreaking scripting > > > >>language > > > >>that extends applications into web and mobile media. Attend the liv= e > > > >>webcast > > > >>and join the prime developer group breaking into this new coding > > > >>territory! > > > >>http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720= &dat=3D121642 > > > >>_______________________________________________ > > > >>Matplotlib-users mailing list > > > >>Mat...@li... > > > >>https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > >> > > > > > > > > > > > >--------------------------------------------------------------------= ---- > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by xPML, a groundbreaking scripting > > > language > > > that extends applications into web and mobile media. Attend the live > > > webcast > > > and join the prime developer group breaking into this new coding > > > territory! > > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&d= at=3D121642 > > > _______________________________________________ > > > Matplotlib-users mailing list > > > Mat...@li... > > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a groundbreaking scripting lang= uage > > that extends applications into web and mobile media. Attend the live we= bcast > > and join the prime developer group breaking into this new coding territ= ory! > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > |
|
From: Arne.Bittig <arn...@in...> - 2006-04-06 13:01:51
|
Yes, that is indeed what I was looking for - and it's significantly easier than I expected. Thanks everybody. Arne Ryan Krauss wrote: > My solution and Darren's do nearly the same thing. > > On 4/6/06, Ryan Krauss <rya...@gm...> wrote: > >>Not a problem. Go into your matplotlibrc file and change these lines: >> >># The figure subplot parameters. All dimensions are fraction of the >># figure width or height >>figure.subplot.left : 0.001 # the left side of the subplots of the figure >>figure.subplot.right : 0.999 # the right side of the subplots of the figure >>figure.subplot.bottom : 0.001 # the bottom of the subplots of the figure >>figure.subplot.top : 0.999 >>figure.subplot.wspace : 0.001 # the amount of width reserved for >>blank space between subplots >>figure.subplot.hspace : 0.001 # the amount of height reserved for >>white space between subplots >> >>They control the white space around the frame where the axes go. With >>the above values, I created the attached plot which I think is close >>to what you want. >> >>Ryan >> >>On 4/6/06, Michael V. De Palatis <mde...@ma...> wrote: >> >>>Arne, >>> >>>I don't know about the "real" solution to this problem, but if you >>>want to go the route of "artificially" solving it with an image >>>library for post processing, you can check out Python Imaging Library: >>> >>>http://www.pythonware.com/products/pil/ >>> >>>Mike >>> >>>On Thu, Apr 06, 2006 at 02:36:55PM +0200, Arne.Bittig wrote: >>> >>>>Sorry, maybe I didn't make that clear enough. >>>> >>>>I was talking about a graph as in "graph theory". Since there is no >>>>meaningful way to label the axes, and, in fact, no reason to show them >>>>at all, the white space I was talking about is just where in your >>>>picture there are the labels. So, looking at your example, what I'd like >>>>to have is what's inside the black rectangle, i.e. a png where the blue >>>>curve touches the top and the bottom of the image. >>>> >>>>Arne >>>> >>>>Ryan Krauss wrote: >>>> >>>> >>>>>I don't think this is the default behavior. If I do >>>>> >>>>>t=arange(0,1,0.01) >>>>>y=sin(2*pi*t) >>>>>plot(t,y) >>>>>xlabel('Time (sec)') >>>>>ylabel('Amplitude') >>>>>savefig('test.png') >>>>> >>>>>I get the attached png without the extra border you describe. >>>>> >>>>>Ryan >>>>> >>>>> >>>>>On 4/6/06, Arne.Bittig <arn...@in...> wrote: >>>>> >>>>> >>>>>>Hi, >>>>>> >>>>>>I am using matplotlib to draw graphs. When I try to save a picture >>>>>>(using savefig; usually as png, but at some point I might need eps files >>>>>>as well), the actual graph comprises less than the central 50% of the >>>>>>image, the rest of the image is wasted space. >>>>>> >>>>>>I already tried figure(frameon = False, facecolor = 'w') and box(False) >>>>>>to get rid of the redundant frame, but apparently it did not help (apart >>>>> >>>>>>from removing the black frame, obviously, but what I want is to save >>>>> >>>>>>only what is inside this frame). >>>>>> >>>>>>Any ideas how to do this? If not, does anyone know a python tool that >>>>>>handles pngs and would enable me to crop the picture in a second step? >>>>>> >>>>>>Arne >>>>>> >>>>>> >>>>>>------------------------------------------------------- >>>>>>This SF.Net email is sponsored by xPML, a groundbreaking scripting >>>>>>language >>>>>>that extends applications into web and mobile media. Attend the live >>>>>>webcast >>>>>>and join the prime developer group breaking into this new coding >>>>>>territory! >>>>>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >>>>>>_______________________________________________ >>>>>>Matplotlib-users mailing list >>>>>>Mat...@li... >>>>>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>>>> >>>>>------------------------------------------------------------------------ >>>>> >>>> >>>> >>>> >>>>------------------------------------------------------- >>>>This SF.Net email is sponsored by xPML, a groundbreaking scripting >>>>language >>>>that extends applications into web and mobile media. Attend the live >>>>webcast >>>>and join the prime developer group breaking into this new coding >>>>territory! >>>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >>>>_______________________________________________ >>>>Matplotlib-users mailing list >>>>Mat...@li... >> >>>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >>>------------------------------------------------------- >>>This SF.Net email is sponsored by xPML, a groundbreaking scripting language >>>that extends applications into web and mobile media. Attend the live webcast >>>and join the prime developer group breaking into this new coding territory! >>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >>>_______________________________________________ >>>Matplotlib-users mailing list >>>Mat...@li... >>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> >> >> |
|
From: Darren D. <dd...@co...> - 2006-04-06 12:48:16
|
On Thursday 06 April 2006 08:36, Arne.Bittig wrote: > Sorry, maybe I didn't make that clear enough. > > I was talking about a graph as in "graph theory". Since there is no > meaningful way to label the axes, and, in fact, no reason to show them > at all, the white space I was talking about is just where in your > picture there are the labels. So, looking at your example, what I'd like > to have is what's inside the black rectangle, i.e. a png where the blue > curve touches the top and the bottom of the image. I think what you want to do is create your axes so they span the entire figure: axes([0,0,1,1]) |