From: Johannes R. <JRa...@gm...> - 2011-05-16 13:21:23
|
Hello, I want to produce a eps file of following mathematical expression: r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' is it possible to somehow missuse matplotlib for that to produce only the function without any other plot things? Or is there a better python library within scipy? I don't want to install the complete latex libraries just for producing this single eps file. thank you /johannes -- NEU: FreePhone - kostenlos mobil telefonieren und surfen! Jetzt informieren: http://www.gmx.net/de/go/freephone |
From: Robert K. <rob...@gm...> - 2011-05-16 13:29:15
|
On Mon, May 16, 2011 at 08:21, Johannes Radinger <JRa...@gm...> wrote: > Hello, > > I want to produce a eps file of following mathematical expression: > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > is it possible to somehow missuse matplotlib for that to produce only the function without any other plot things? Or is there a better python library within scipy? I don't want to install the complete latex libraries just for producing this single eps file. Check out mathtex. It is matplotlib's TeX parsing engine and renderer broken out into a separate library: http://code.google.com/p/mathtex/ Also, please send matplotlib questions just to the matplotlib list. Thanks. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Johannes R. <JRa...@gm...> - 2011-05-16 14:23:34
|
-------- Original-Nachricht -------- > Datum: Mon, 16 May 2011 08:28:49 -0500 > Von: Robert Kern <rob...@gm...> > An: SciPy Users List <sci...@sc...> > CC: mat...@li... > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce mathathematical expression only > On Mon, May 16, 2011 at 08:21, Johannes Radinger <JRa...@gm...> wrote: > > Hello, > > > > I want to produce a eps file of following mathematical expression: > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > > > is it possible to somehow missuse matplotlib for that to produce only > the function without any other plot things? Or is there a better python > library within scipy? I don't want to install the complete latex libraries just > for producing this single eps file. > > Check out mathtex. It is matplotlib's TeX parsing engine and renderer > broken out into a separate library: > > http://code.google.com/p/mathtex/ I also thought about mathtex but don't know how to use my mathematical expression without a plot of axis etc. any suggestions? I just want to have the formated math expression as eps and I don't know how to do it, still after reading in the matplotlib-manual. /johannes > > Also, please send matplotlib questions just to the matplotlib list. > Thanks. > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma that is made terrible by our own mad attempt to interpret it as > though it had an underlying truth." > -- Umberto Eco > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- NEU: FreePhone - kostenlos mobil telefonieren und surfen! Jetzt informieren: http://www.gmx.net/de/go/freephone |
From: Benjamin R. <ben...@ou...> - 2011-05-16 14:49:31
|
On Monday, May 16, 2011, Johannes Radinger <JRa...@gm...> wrote: > > -------- Original-Nachricht -------- >> Datum: Mon, 16 May 2011 08:28:49 -0500 >> Von: Robert Kern <rob...@gm...> >> An: SciPy Users List <sci...@sc...> >> CC: mat...@li... >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce mathathematical expression only > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger <JRa...@gm...> wrote: >> > Hello, >> > >> > I want to produce a eps file of following mathematical expression: >> > >> r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' >> > >> > is it possible to somehow missuse matplotlib for that to produce only >> the function without any other plot things? Or is there a better python >> library within scipy? I don't want to install the complete latex libraries just >> for producing this single eps file. >> >> Check out mathtex. It is matplotlib's TeX parsing engine and renderer >> broken out into a separate library: >> >> http://code.google.com/p/mathtex/ > > I also thought about mathtex but don't know how to use my mathematical expression without a plot of axis etc. any suggestions? I just want to have the formated math expression as eps and I don't know how to do it, still after reading in the matplotlib-manual. > > /johannes > > >> >> Also, please send matplotlib questions just to the matplotlib list. >> Thanks. >> >> -- >> Robert Kern >> >> "I have come to believe that the whole world is an enigma, a harmless >> enigma that is made terrible by our own mad attempt to interpret it as >> though it had an underlying truth." >> -- Umberto Eco >> >> ------------------------------------------------------------------------------ >> Achieve unprecedented app performance and reliability >> What every C/C++ and Fortran developer should know. >> Learn how Intel has extended the reach of its next-generation tools >> to help boost performance applications - inlcuding clusters. >> http://p.sf.net/sfu/intel-dev2devmay >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > Jetzt informieren: http://www.gmx.net/de/go/freephone > _______________________________________________ > SciPy-User mailing list > Sci...@sc... > http://mail.scipy.org/mailman/listinfo/scipy-user > We have added a new feature to do just that in the development branch, but it should be fairly trivial to do with existing releases of matplotlib. Just create a figure object and use its figtitle to hold the expression and then save the figure. Ben Root |
From: Johannes R. <JRa...@gm...> - 2011-05-16 15:21:47
|
-------- Original-Nachricht -------- > Datum: Mon, 16 May 2011 09:49:24 -0500 > Von: Benjamin Root <ben...@ou...> > An: "mat...@li..." <mat...@li...> > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce mathathematical expression only > On Monday, May 16, 2011, Johannes Radinger <JRa...@gm...> wrote: > > > > -------- Original-Nachricht -------- > >> Datum: Mon, 16 May 2011 08:28:49 -0500 > >> Von: Robert Kern <rob...@gm...> > >> An: SciPy Users List <sci...@sc...> > >> CC: mat...@li... > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce > mathathematical expression only > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger <JRa...@gm...> > wrote: > >> > Hello, > >> > > >> > I want to produce a eps file of following mathematical expression: > >> > > >> > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > >> > > >> > is it possible to somehow missuse matplotlib for that to produce only > >> the function without any other plot things? Or is there a better python > >> library within scipy? I don't want to install the complete latex > libraries just > >> for producing this single eps file. > >> > >> Check out mathtex. It is matplotlib's TeX parsing engine and renderer > >> broken out into a separate library: > >> > >> http://code.google.com/p/mathtex/ > > > > I also thought about mathtex but don't know how to use my mathematical > expression without a plot of axis etc. any suggestions? I just want to have > the formated math expression as eps and I don't know how to do it, still > after reading in the matplotlib-manual. > > > > /johannes > > > > > >> > >> Also, please send matplotlib questions just to the matplotlib list. > >> Thanks. > >> > >> -- > >> Robert Kern > >> > >> "I have come to believe that the whole world is an enigma, a harmless > >> enigma that is made terrible by our own mad attempt to interpret it as > >> though it had an underlying truth." > >> -- Umberto Eco > >> > >> > ------------------------------------------------------------------------------ > >> Achieve unprecedented app performance and reliability > >> What every C/C++ and Fortran developer should know. > >> Learn how Intel has extended the reach of its next-generation tools > >> to help boost performance applications - inlcuding clusters. > >> http://p.sf.net/sfu/intel-dev2devmay > >> _______________________________________________ > >> Matplotlib-users mailing list > >> Mat...@li... > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > -- > > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > > Jetzt informieren: http://www.gmx.net/de/go/freephone > > _______________________________________________ > > SciPy-User mailing list > > Sci...@sc... > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > We have added a new feature to do just that in the development branch, > but it should be fairly trivial to do with existing releases of > matplotlib. Just create a figure object and use its figtitle to hold > the expression and then save the figure. It might be trivial but how to remove the axis/plot then and crop the extend of the eps? I tried: plt.figure() plt.title(r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', fontsize=20) plt.show() /j > > Ben Root > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- NEU: FreePhone - kostenlos mobil telefonieren und surfen! Jetzt informieren: http://www.gmx.net/de/go/freephone |
From: Benjamin R. <ben...@ou...> - 2011-05-16 16:00:00
|
On Mon, May 16, 2011 at 10:21 AM, Johannes Radinger <JRa...@gm...>wrote: > > -------- Original-Nachricht -------- > > Datum: Mon, 16 May 2011 09:49:24 -0500 > > Von: Benjamin Root <ben...@ou...> > > An: "mat...@li..." < > mat...@li...> > > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce > mathathematical expression only > > > On Monday, May 16, 2011, Johannes Radinger <JRa...@gm...> wrote: > > > > > > -------- Original-Nachricht -------- > > >> Datum: Mon, 16 May 2011 08:28:49 -0500 > > >> Von: Robert Kern <rob...@gm...> > > >> An: SciPy Users List <sci...@sc...> > > >> CC: mat...@li... > > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce > > mathathematical expression only > > > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger <JRa...@gm...> > > wrote: > > >> > Hello, > > >> > > > >> > I want to produce a eps file of following mathematical expression: > > >> > > > >> > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > >> > > > >> > is it possible to somehow missuse matplotlib for that to produce > only > > >> the function without any other plot things? Or is there a better > python > > >> library within scipy? I don't want to install the complete latex > > libraries just > > >> for producing this single eps file. > > >> > > >> Check out mathtex. It is matplotlib's TeX parsing engine and renderer > > >> broken out into a separate library: > > >> > > >> http://code.google.com/p/mathtex/ > > > > > > I also thought about mathtex but don't know how to use my mathematical > > expression without a plot of axis etc. any suggestions? I just want to > have > > the formated math expression as eps and I don't know how to do it, still > > after reading in the matplotlib-manual. > > > > > > /johannes > > > > > > > > >> > > >> Also, please send matplotlib questions just to the matplotlib list. > > >> Thanks. > > >> > > >> -- > > >> Robert Kern > > >> > > >> "I have come to believe that the whole world is an enigma, a harmless > > >> enigma that is made terrible by our own mad attempt to interpret it as > > >> though it had an underlying truth." > > >> -- Umberto Eco > > >> > > >> > > > ------------------------------------------------------------------------------ > > >> Achieve unprecedented app performance and reliability > > >> What every C/C++ and Fortran developer should know. > > >> Learn how Intel has extended the reach of its next-generation tools > > >> to help boost performance applications - inlcuding clusters. > > >> http://p.sf.net/sfu/intel-dev2devmay > > >> _______________________________________________ > > >> Matplotlib-users mailing list > > >> Mat...@li... > > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > -- > > > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > > > Jetzt informieren: http://www.gmx.net/de/go/freephone > > > _______________________________________________ > > > SciPy-User mailing list > > > Sci...@sc... > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > We have added a new feature to do just that in the development branch, > > but it should be fairly trivial to do with existing releases of > > matplotlib. Just create a figure object and use its figtitle to hold > > the expression and then save the figure. > > It might be trivial but how to remove the axis/plot then and crop the > extend of the eps? > > I tried: > > plt.figure() > plt.title(r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > fontsize=20) > plt.show() > > /j > > Use figtext instead. I did the following and it looked fine to me: plt.figure() plt.figtext(0.1, 0.5, r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', fontsize=20) plt.show() I hope that helps! Ben Root |
From: Johannes R. <JRa...@gm...> - 2011-05-16 16:23:08
|
-------- Original-Nachricht -------- > Datum: Mon, 16 May 2011 10:59:34 -0500 > Von: Benjamin Root <ben...@ou...> > An: Johannes Radinger <JRa...@gm...> > CC: mat...@li... > Betreff: Re: [Matplotlib-users] use matplotlib to produce mathathematical expression only > On Mon, May 16, 2011 at 10:21 AM, Johannes Radinger > <JRa...@gm...>wrote: > > > > > -------- Original-Nachricht -------- > > > Datum: Mon, 16 May 2011 09:49:24 -0500 > > > Von: Benjamin Root <ben...@ou...> > > > An: "mat...@li..." < > > mat...@li...> > > > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce > > mathathematical expression only > > > > > On Monday, May 16, 2011, Johannes Radinger <JRa...@gm...> wrote: > > > > > > > > -------- Original-Nachricht -------- > > > >> Datum: Mon, 16 May 2011 08:28:49 -0500 > > > >> Von: Robert Kern <rob...@gm...> > > > >> An: SciPy Users List <sci...@sc...> > > > >> CC: mat...@li... > > > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to > produce > > > mathathematical expression only > > > > > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger <JRa...@gm...> > > > wrote: > > > >> > Hello, > > > >> > > > > >> > I want to produce a eps file of following mathematical > expression: > > > >> > > > > >> > > > > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > > >> > > > > >> > is it possible to somehow missuse matplotlib for that to produce > > only > > > >> the function without any other plot things? Or is there a better > > python > > > >> library within scipy? I don't want to install the complete latex > > > libraries just > > > >> for producing this single eps file. > > > >> > > > >> Check out mathtex. It is matplotlib's TeX parsing engine and > renderer > > > >> broken out into a separate library: > > > >> > > > >> http://code.google.com/p/mathtex/ > > > > > > > > I also thought about mathtex but don't know how to use my > mathematical > > > expression without a plot of axis etc. any suggestions? I just want to > > have > > > the formated math expression as eps and I don't know how to do it, > still > > > after reading in the matplotlib-manual. > > > > > > > > /johannes > > > > > > > > > > > >> > > > >> Also, please send matplotlib questions just to the matplotlib list. > > > >> Thanks. > > > >> > > > >> -- > > > >> Robert Kern > > > >> > > > >> "I have come to believe that the whole world is an enigma, a > harmless > > > >> enigma that is made terrible by our own mad attempt to interpret it > as > > > >> though it had an underlying truth." > > > >> -- Umberto Eco > > > >> > > > >> > > > > > > ------------------------------------------------------------------------------ > > > >> Achieve unprecedented app performance and reliability > > > >> What every C/C++ and Fortran developer should know. > > > >> Learn how Intel has extended the reach of its next-generation tools > > > >> to help boost performance applications - inlcuding clusters. > > > >> http://p.sf.net/sfu/intel-dev2devmay > > > >> _______________________________________________ > > > >> Matplotlib-users mailing list > > > >> Mat...@li... > > > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > -- > > > > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > > > > Jetzt informieren: http://www.gmx.net/de/go/freephone > > > > _______________________________________________ > > > > SciPy-User mailing list > > > > Sci...@sc... > > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > > > > We have added a new feature to do just that in the development branch, > > > but it should be fairly trivial to do with existing releases of > > > matplotlib. Just create a figure object and use its figtitle to hold > > > the expression and then save the figure. > > > > It might be trivial but how to remove the axis/plot then and crop the > > extend of the eps? > > > > I tried: > > > > plt.figure() > > > plt.title(r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > fontsize=20) > > plt.show() > > > > /j > > > > > Use figtext instead. I did the following and it looked fine to me: > > plt.figure() > plt.figtext(0.1, 0.5, > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > fontsize=20) > plt.show() > thats working nearly perfect, I would just need to crop the display extend resp. the white space from the eps around...any option/idea? /j > > I hope that helps! > Ben Root -- NEU: FreePhone - kostenlos mobil telefonieren und surfen! Jetzt informieren: http://www.gmx.net/de/go/freephone |
From: Robert K. <rob...@gm...> - 2011-05-16 15:06:46
|
On Mon, May 16, 2011 at 09:23, Johannes Radinger <JRa...@gm...> wrote: > > -------- Original-Nachricht -------- >> Datum: Mon, 16 May 2011 08:28:49 -0500 >> Von: Robert Kern <rob...@gm...> >> An: SciPy Users List <sci...@sc...> >> CC: mat...@li... >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to produce mathathematical expression only > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger <JRa...@gm...> wrote: >> > Hello, >> > >> > I want to produce a eps file of following mathematical expression: >> > >> r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' >> > >> > is it possible to somehow missuse matplotlib for that to produce only >> the function without any other plot things? Or is there a better python >> library within scipy? I don't want to install the complete latex libraries just >> for producing this single eps file. >> >> Check out mathtex. It is matplotlib's TeX parsing engine and renderer >> broken out into a separate library: >> >> http://code.google.com/p/mathtex/ > > I also thought about mathtex but don't know how to use my mathematical expression without a plot of axis etc. any suggestions? I just want to have the formated math expression as eps and I don't know how to do it, still after reading in the matplotlib-manual. The mathtex that I link to above is a separate library, not a part of matplotlib. Please follow the link. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Benjamin R. <ben...@ou...> - 2011-05-16 16:36:45
|
On Mon, May 16, 2011 at 11:22 AM, Johannes Radinger <JRa...@gm...>wrote: > > -------- Original-Nachricht -------- > > Datum: Mon, 16 May 2011 10:59:34 -0500 > > Von: Benjamin Root <ben...@ou...> > > An: Johannes Radinger <JRa...@gm...> > > CC: mat...@li... > > Betreff: Re: [Matplotlib-users] use matplotlib to produce mathathematical > expression only > > > On Mon, May 16, 2011 at 10:21 AM, Johannes Radinger > > <JRa...@gm...>wrote: > > > > > > > > -------- Original-Nachricht -------- > > > > Datum: Mon, 16 May 2011 09:49:24 -0500 > > > > Von: Benjamin Root <ben...@ou...> > > > > An: "mat...@li..." < > > > mat...@li...> > > > > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to > produce > > > mathathematical expression only > > > > > > > On Monday, May 16, 2011, Johannes Radinger <JRa...@gm...> wrote: > > > > > > > > > > -------- Original-Nachricht -------- > > > > >> Datum: Mon, 16 May 2011 08:28:49 -0500 > > > > >> Von: Robert Kern <rob...@gm...> > > > > >> An: SciPy Users List <sci...@sc...> > > > > >> CC: mat...@li... > > > > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to > > produce > > > > mathathematical expression only > > > > > > > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger < > JRa...@gm...> > > > > wrote: > > > > >> > Hello, > > > > >> > > > > > >> > I want to produce a eps file of following mathematical > > expression: > > > > >> > > > > > >> > > > > > > > > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > > > >> > > > > > >> > is it possible to somehow missuse matplotlib for that to produce > > > only > > > > >> the function without any other plot things? Or is there a better > > > python > > > > >> library within scipy? I don't want to install the complete latex > > > > libraries just > > > > >> for producing this single eps file. > > > > >> > > > > >> Check out mathtex. It is matplotlib's TeX parsing engine and > > renderer > > > > >> broken out into a separate library: > > > > >> > > > > >> http://code.google.com/p/mathtex/ > > > > > > > > > > I also thought about mathtex but don't know how to use my > > mathematical > > > > expression without a plot of axis etc. any suggestions? I just want > to > > > have > > > > the formated math expression as eps and I don't know how to do it, > > still > > > > after reading in the matplotlib-manual. > > > > > > > > > > /johannes > > > > > > > > > > > > > > >> > > > > >> Also, please send matplotlib questions just to the matplotlib > list. > > > > >> Thanks. > > > > >> > > > > >> -- > > > > >> Robert Kern > > > > >> > > > > >> "I have come to believe that the whole world is an enigma, a > > harmless > > > > >> enigma that is made terrible by our own mad attempt to interpret > it > > as > > > > >> though it had an underlying truth." > > > > >> -- Umberto Eco > > > > >> > > > > >> > > > > > > > > > > ------------------------------------------------------------------------------ > > > > >> Achieve unprecedented app performance and reliability > > > > >> What every C/C++ and Fortran developer should know. > > > > >> Learn how Intel has extended the reach of its next-generation > tools > > > > >> to help boost performance applications - inlcuding clusters. > > > > >> http://p.sf.net/sfu/intel-dev2devmay > > > > >> _______________________________________________ > > > > >> Matplotlib-users mailing list > > > > >> Mat...@li... > > > > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > -- > > > > > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > > > > > Jetzt informieren: http://www.gmx.net/de/go/freephone > > > > > _______________________________________________ > > > > > SciPy-User mailing list > > > > > Sci...@sc... > > > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > > > > > > > We have added a new feature to do just that in the development > branch, > > > > but it should be fairly trivial to do with existing releases of > > > > matplotlib. Just create a figure object and use its figtitle to hold > > > > the expression and then save the figure. > > > > > > It might be trivial but how to remove the axis/plot then and crop the > > > extend of the eps? > > > > > > I tried: > > > > > > plt.figure() > > > > > > plt.title(r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > > fontsize=20) > > > plt.show() > > > > > > /j > > > > > > > > Use figtext instead. I did the following and it looked fine to me: > > > > plt.figure() > > plt.figtext(0.1, 0.5, > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > fontsize=20) > > plt.show() > > > > > thats working nearly perfect, I would just need to crop the display extend > resp. the white space from the eps around...any option/idea? > > > /j > > Try setting bbox_inches='tight' in the call to savefig. With bbox_inches='tight', you can then specify the 'pad_inches' kwarg to indicate how much padding to put around the tight bounding box. This should work, however some older version of matplotlib might not check the figure text objects for calculating the tightest bounding box. In that case, the way that I typically autocrop my eps files is to convert it into a pdf file and use pdfcrop and then convert it back to eps (assuming you have a standard linux install). Here is the chain of commands I typically use on my Fedora machine: epstopdf mathtext.eps --outfile=mathtext.temp.pdf pdfcrop --margins '15 2 15 2' --clip mathtext.temp.pdf mathtext.cropped.pdf pdftops mathtext.cropped.pdf mathtext.cropped.eps You can adjust margins to your tastes, and the names of the files are fairly arbitrary. I hope that helps! Ben Root |
From: Michael D. <md...@st...> - 2011-05-16 18:09:05
|
<https://github.com/matplotlib/matplotlib/commit/44d3cf8cb883a85c325459165b6ed120219c7451>Below is the new function that was recently added to the development version (that Benjamin was referring to). It should work to include it in your own code and should work for the past few releases of matplotlib. It gets around the need for any external tools for cropping etc since the tight bounding box is calculated within matplotlib. Mike def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None): """ Given a math expression, renders it in a closely-clipped bounding box to an image file. *s* A math expression. The math portion should be enclosed in dollar signs. *filename_or_obj* A filepath or writable file-like object to write the image data to. *prop* If provided, a FontProperties() object describing the size and style of the text. *dpi* Override the output dpi, otherwise use the default associated with the output format. *format* The output format, eg. 'svg', 'pdf', 'ps' or 'png'. If not provided, will be deduced from the filename. """ from matplotlib import figure # backend_agg supports all of the core output formats from matplotlib.backends import backend_agg if prop is None: prop = FontProperties() parser = MathTextParser('path') width, height, depth, _, _ = parser.parse(s, dpi=72, prop=prop) fig = figure.Figure(figsize=(width / 72.0, height / 72.0)) fig.text(0, depth/height, s, fontproperties=prop) backend_agg.FigureCanvasAgg(fig) fig.savefig(filename_or_obj, dpi=dpi, format=format) return depth On 05/16/2011 12:36 PM, Benjamin Root wrote: > > > On Mon, May 16, 2011 at 11:22 AM, Johannes Radinger <JRa...@gm... > <mailto:JRa...@gm...>> wrote: > > > -------- Original-Nachricht -------- > > Datum: Mon, 16 May 2011 10:59:34 -0500 > > Von: Benjamin Root <ben...@ou... <mailto:ben...@ou...>> > > An: Johannes Radinger <JRa...@gm... <mailto:JRa...@gm...>> > > CC: mat...@li... > <mailto:mat...@li...> > > Betreff: Re: [Matplotlib-users] use matplotlib to produce > mathathematical expression only > > > On Mon, May 16, 2011 at 10:21 AM, Johannes Radinger > > <JRa...@gm... <mailto:JRa...@gm...>>wrote: > > > > > > > > -------- Original-Nachricht -------- > > > > Datum: Mon, 16 May 2011 09:49:24 -0500 > > > > Von: Benjamin Root <ben...@ou... <mailto:ben...@ou...>> > > > > An: "mat...@li... > <mailto:mat...@li...>" < > > > mat...@li... > <mailto:mat...@li...>> > > > > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib > to produce > > > mathathematical expression only > > > > > > > On Monday, May 16, 2011, Johannes Radinger <JRa...@gm... > <mailto:JRa...@gm...>> wrote: > > > > > > > > > > -------- Original-Nachricht -------- > > > > >> Datum: Mon, 16 May 2011 08:28:49 -0500 > > > > >> Von: Robert Kern <rob...@gm... > <mailto:rob...@gm...>> > > > > >> An: SciPy Users List <sci...@sc... > <mailto:sci...@sc...>> > > > > >> CC: mat...@li... > <mailto:mat...@li...> > > > > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use > matplotlib to > > produce > > > > mathathematical expression only > > > > > > > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger > <JRa...@gm... <mailto:JRa...@gm...>> > > > > wrote: > > > > >> > Hello, > > > > >> > > > > > >> > I want to produce a eps file of following mathematical > > expression: > > > > >> > > > > > >> > > > > > > > > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > > > >> > > > > > >> > is it possible to somehow missuse matplotlib for that > to produce > > > only > > > > >> the function without any other plot things? Or is there a > better > > > python > > > > >> library within scipy? I don't want to install the > complete latex > > > > libraries just > > > > >> for producing this single eps file. > > > > >> > > > > >> Check out mathtex. It is matplotlib's TeX parsing engine and > > renderer > > > > >> broken out into a separate library: > > > > >> > > > > >> http://code.google.com/p/mathtex/ > > > > > > > > > > I also thought about mathtex but don't know how to use my > > mathematical > > > > expression without a plot of axis etc. any suggestions? I > just want to > > > have > > > > the formated math expression as eps and I don't know how to > do it, > > still > > > > after reading in the matplotlib-manual. > > > > > > > > > > /johannes > > > > > > > > > > > > > > >> > > > > >> Also, please send matplotlib questions just to the > matplotlib list. > > > > >> Thanks. > > > > >> > > > > >> -- > > > > >> Robert Kern > > > > >> > > > > >> "I have come to believe that the whole world is an enigma, a > > harmless > > > > >> enigma that is made terrible by our own mad attempt to > interpret it > > as > > > > >> though it had an underlying truth." > > > > >> -- Umberto Eco > > > > >> > > > > >> > > > > > > > > > > ------------------------------------------------------------------------------ > > > > >> Achieve unprecedented app performance and reliability > > > > >> What every C/C++ and Fortran developer should know. > > > > >> Learn how Intel has extended the reach of its > next-generation tools > > > > >> to help boost performance applications - inlcuding clusters. > > > > >> http://p.sf.net/sfu/intel-dev2devmay > > > > >> _______________________________________________ > > > > >> Matplotlib-users mailing list > > > > >> Mat...@li... > <mailto:Mat...@li...> > > > > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > -- > > > > > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > > > > > Jetzt informieren: http://www.gmx.net/de/go/freephone > > > > > _______________________________________________ > > > > > SciPy-User mailing list > > > > > Sci...@sc... <mailto:Sci...@sc...> > > > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > > > > > > > We have added a new feature to do just that in the > development branch, > > > > but it should be fairly trivial to do with existing releases of > > > > matplotlib. Just create a figure object and use its > figtitle to hold > > > > the expression and then save the figure. > > > > > > It might be trivial but how to remove the axis/plot then and > crop the > > > extend of the eps? > > > > > > I tried: > > > > > > plt.figure() > > > > > > plt.title(r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > > fontsize=20) > > > plt.show() > > > > > > /j > > > > > > > > Use figtext instead. I did the following and it looked fine to me: > > > > plt.figure() > > plt.figtext(0.1, 0.5, > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > fontsize=20) > > plt.show() > > > > > thats working nearly perfect, I would just need to crop the > display extend resp. the white space from the eps around...any > option/idea? > > > /j > > > Try setting bbox_inches='tight' in the call to savefig. With > bbox_inches='tight', you can then specify the 'pad_inches' kwarg to > indicate how much padding to put around the tight bounding box. This > should work, however some older version of matplotlib might not check > the figure text objects for calculating the tightest bounding box. In > that case, the way that I typically autocrop my eps files is to > convert it into a pdf file and use pdfcrop and then convert it back to > eps (assuming you have a standard linux install). Here is the chain > of commands I typically use on my Fedora machine: > > epstopdf mathtext.eps --outfile=mathtext.temp.pdf > pdfcrop --margins '15 2 15 2' --clip mathtext.temp.pdf > mathtext.cropped.pdf > pdftops mathtext.cropped.pdf mathtext.cropped.eps > > You can adjust margins to your tastes, and the names of the files are > fairly arbitrary. > > I hope that helps! > Ben Root > > > ------------------------------------------------------------------------------ > Achieve unprecedented app performance and reliability > What every C/C++ and Fortran developer should know. > Learn how Intel has extended the reach of its next-generation tools > to help boost performance applications - inlcuding clusters. > http://p.sf.net/sfu/intel-dev2devmay > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Space Telescope Science Institute Baltimore, Maryland, USA |
From: Johannes R. <JRa...@gm...> - 2011-05-17 07:59:01
|
-------- Original-Nachricht -------- > Datum: Mon, 16 May 2011 11:36:18 -0500 > Von: Benjamin Root <ben...@ou...> > An: Johannes Radinger <JRa...@gm...> > CC: mat...@li... > Betreff: Re: [Matplotlib-users] use matplotlib to produce mathathematical expression only > On Mon, May 16, 2011 at 11:22 AM, Johannes Radinger > <JRa...@gm...>wrote: > > > > > -------- Original-Nachricht -------- > > > Datum: Mon, 16 May 2011 10:59:34 -0500 > > > Von: Benjamin Root <ben...@ou...> > > > An: Johannes Radinger <JRa...@gm...> > > > CC: mat...@li... > > > Betreff: Re: [Matplotlib-users] use matplotlib to produce > mathathematical > > expression only > > > > > On Mon, May 16, 2011 at 10:21 AM, Johannes Radinger > > > <JRa...@gm...>wrote: > > > > > > > > > > > -------- Original-Nachricht -------- > > > > > Datum: Mon, 16 May 2011 09:49:24 -0500 > > > > > Von: Benjamin Root <ben...@ou...> > > > > > An: "mat...@li..." < > > > > mat...@li...> > > > > > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to > > produce > > > > mathathematical expression only > > > > > > > > > On Monday, May 16, 2011, Johannes Radinger <JRa...@gm...> > wrote: > > > > > > > > > > > > -------- Original-Nachricht -------- > > > > > >> Datum: Mon, 16 May 2011 08:28:49 -0500 > > > > > >> Von: Robert Kern <rob...@gm...> > > > > > >> An: SciPy Users List <sci...@sc...> > > > > > >> CC: mat...@li... > > > > > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to > > > produce > > > > > mathathematical expression only > > > > > > > > > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger < > > JRa...@gm...> > > > > > wrote: > > > > > >> > Hello, > > > > > >> > > > > > > >> > I want to produce a eps file of following mathematical > > > expression: > > > > > >> > > > > > > >> > > > > > > > > > > > > > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > > > > >> > > > > > > >> > is it possible to somehow missuse matplotlib for that to > produce > > > > only > > > > > >> the function without any other plot things? Or is there a > better > > > > python > > > > > >> library within scipy? I don't want to install the complete > latex > > > > > libraries just > > > > > >> for producing this single eps file. > > > > > >> > > > > > >> Check out mathtex. It is matplotlib's TeX parsing engine and > > > renderer > > > > > >> broken out into a separate library: > > > > > >> > > > > > >> http://code.google.com/p/mathtex/ > > > > > > > > > > > > I also thought about mathtex but don't know how to use my > > > mathematical > > > > > expression without a plot of axis etc. any suggestions? I just > want > > to > > > > have > > > > > the formated math expression as eps and I don't know how to do it, > > > still > > > > > after reading in the matplotlib-manual. > > > > > > > > > > > > /johannes > > > > > > > > > > > > > > > > > >> > > > > > >> Also, please send matplotlib questions just to the matplotlib > > list. > > > > > >> Thanks. > > > > > >> > > > > > >> -- > > > > > >> Robert Kern > > > > > >> > > > > > >> "I have come to believe that the whole world is an enigma, a > > > harmless > > > > > >> enigma that is made terrible by our own mad attempt to > interpret > > it > > > as > > > > > >> though it had an underlying truth." > > > > > >> -- Umberto Eco > > > > > >> > > > > > >> > > > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > > > > >> Achieve unprecedented app performance and reliability > > > > > >> What every C/C++ and Fortran developer should know. > > > > > >> Learn how Intel has extended the reach of its next-generation > > tools > > > > > >> to help boost performance applications - inlcuding clusters. > > > > > >> http://p.sf.net/sfu/intel-dev2devmay > > > > > >> _______________________________________________ > > > > > >> Matplotlib-users mailing list > > > > > >> Mat...@li... > > > > > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > > > -- > > > > > > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > > > > > > Jetzt informieren: http://www.gmx.net/de/go/freephone > > > > > > _______________________________________________ > > > > > > SciPy-User mailing list > > > > > > Sci...@sc... > > > > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > > > > > > > > > > We have added a new feature to do just that in the development > > branch, > > > > > but it should be fairly trivial to do with existing releases of > > > > > matplotlib. Just create a figure object and use its figtitle to > hold > > > > > the expression and then save the figure. > > > > > > > > It might be trivial but how to remove the axis/plot then and crop > the > > > > extend of the eps? > > > > > > > > I tried: > > > > > > > > plt.figure() > > > > > > > > > > plt.title(r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > > > fontsize=20) > > > > plt.show() > > > > > > > > /j > > > > > > > > > > > Use figtext instead. I did the following and it looked fine to me: > > > > > > plt.figure() > > > plt.figtext(0.1, 0.5, > > > > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > > fontsize=20) > > > plt.show() > > > > > > > > > thats working nearly perfect, I would just need to crop the display > extend > > resp. the white space from the eps around...any option/idea? > > > > > > /j > > > > > Try setting bbox_inches='tight' in the call to savefig. With > bbox_inches='tight', you can then specify the 'pad_inches' kwarg to > indicate > how much padding to put around the tight bounding box. This should work, > however some older version of matplotlib might not check the figure text > objects for calculating the tightest bounding box. Hej, I tried your suggestion like: plt.figure() plt.figtext(0.01, 0.5,r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', fontsize=26) #plt.show() plt.savefig("testplot.eps", bbox_inches='tight') but get following error: plt.savefig("testplot.eps", bbox_inches='tight') File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", line 363, in savefig return fig.savefig(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", line 1084, in savefig self.canvas.print_figure(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backend_bases.py", line 1891, in print_figure bbox_inches = self.figure.get_tightbbox(renderer) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", line 1212, in get_tightbbox _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/transforms.py", line 675, in union assert(len(bboxes)) AssertionError For your information: I work with python 2.6.6 and matplotlib 1.0.1 on Mac OS X 10.6.6 /j In that case, the way > that I typically autocrop my eps files is to convert it into a pdf file > and > use pdfcrop and then convert it back to eps (assuming you have a standard > linux install). Here is the chain of commands I typically use on my > Fedora > machine: > > epstopdf mathtext.eps --outfile=mathtext.temp.pdf > pdfcrop --margins '15 2 15 2' --clip mathtext.temp.pdf > mathtext.cropped.pdf > pdftops mathtext.cropped.pdf mathtext.cropped.eps > > You can adjust margins to your tastes, and the names of the files are > fairly > arbitrary. > > I hope that helps! > Ben Root -- NEU: FreePhone - kostenlos mobil telefonieren und surfen! Jetzt informieren: http://www.gmx.net/de/go/freephone |
From: Benjamin R. <ben...@ou...> - 2011-05-17 14:43:30
|
On Tue, May 17, 2011 at 2:58 AM, Johannes Radinger <JRa...@gm...> wrote: > > -------- Original-Nachricht -------- > > Datum: Mon, 16 May 2011 11:36:18 -0500 > > Von: Benjamin Root <ben...@ou...> > > An: Johannes Radinger <JRa...@gm...> > > CC: mat...@li... > > Betreff: Re: [Matplotlib-users] use matplotlib to produce mathathematical > expression only > > > On Mon, May 16, 2011 at 11:22 AM, Johannes Radinger > > <JRa...@gm...>wrote: > > > > > > > > -------- Original-Nachricht -------- > > > > Datum: Mon, 16 May 2011 10:59:34 -0500 > > > > Von: Benjamin Root <ben...@ou...> > > > > An: Johannes Radinger <JRa...@gm...> > > > > CC: mat...@li... > > > > Betreff: Re: [Matplotlib-users] use matplotlib to produce > > mathathematical > > > expression only > > > > > > > On Mon, May 16, 2011 at 10:21 AM, Johannes Radinger > > > > <JRa...@gm...>wrote: > > > > > > > > > > > > > > -------- Original-Nachricht -------- > > > > > > Datum: Mon, 16 May 2011 09:49:24 -0500 > > > > > > Von: Benjamin Root <ben...@ou...> > > > > > > An: "mat...@li..." < > > > > > mat...@li...> > > > > > > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to > > > produce > > > > > mathathematical expression only > > > > > > > > > > > On Monday, May 16, 2011, Johannes Radinger <JRa...@gm...> > > wrote: > > > > > > > > > > > > > > -------- Original-Nachricht -------- > > > > > > >> Datum: Mon, 16 May 2011 08:28:49 -0500 > > > > > > >> Von: Robert Kern <rob...@gm...> > > > > > > >> An: SciPy Users List <sci...@sc...> > > > > > > >> CC: mat...@li... > > > > > > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to > > > > produce > > > > > > mathathematical expression only > > > > > > > > > > > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger < > > > JRa...@gm...> > > > > > > wrote: > > > > > > >> > Hello, > > > > > > >> > > > > > > > >> > I want to produce a eps file of following mathematical > > > > expression: > > > > > > >> > > > > > > > >> > > > > > > > > > > > > > > > > > > > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$' > > > > > > >> > > > > > > > >> > is it possible to somehow missuse matplotlib for that to > > produce > > > > > only > > > > > > >> the function without any other plot things? Or is there a > > better > > > > > python > > > > > > >> library within scipy? I don't want to install the complete > > latex > > > > > > libraries just > > > > > > >> for producing this single eps file. > > > > > > >> > > > > > > >> Check out mathtex. It is matplotlib's TeX parsing engine and > > > > renderer > > > > > > >> broken out into a separate library: > > > > > > >> > > > > > > >> http://code.google.com/p/mathtex/ > > > > > > > > > > > > > > I also thought about mathtex but don't know how to use my > > > > mathematical > > > > > > expression without a plot of axis etc. any suggestions? I just > > want > > > to > > > > > have > > > > > > the formated math expression as eps and I don't know how to do > it, > > > > still > > > > > > after reading in the matplotlib-manual. > > > > > > > > > > > > > > /johannes > > > > > > > > > > > > > > > > > > > > >> > > > > > > >> Also, please send matplotlib questions just to the matplotlib > > > list. > > > > > > >> Thanks. > > > > > > >> > > > > > > >> -- > > > > > > >> Robert Kern > > > > > > >> > > > > > > >> "I have come to believe that the whole world is an enigma, a > > > > harmless > > > > > > >> enigma that is made terrible by our own mad attempt to > > interpret > > > it > > > > as > > > > > > >> though it had an underlying truth." > > > > > > >> -- Umberto Eco > > > > > > >> > > > > > > >> > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > > > > > >> Achieve unprecedented app performance and reliability > > > > > > >> What every C/C++ and Fortran developer should know. > > > > > > >> Learn how Intel has extended the reach of its next-generation > > > tools > > > > > > >> to help boost performance applications - inlcuding clusters. > > > > > > >> http://p.sf.net/sfu/intel-dev2devmay > > > > > > >> _______________________________________________ > > > > > > >> Matplotlib-users mailing list > > > > > > >> Mat...@li... > > > > > > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > > > > > > > > > -- > > > > > > > NEU: FreePhone - kostenlos mobil telefonieren und surfen! > > > > > > > Jetzt informieren: http://www.gmx.net/de/go/freephone > > > > > > > _______________________________________________ > > > > > > > SciPy-User mailing list > > > > > > > Sci...@sc... > > > > > > > http://mail.scipy.org/mailman/listinfo/scipy-user > > > > > > > > > > > > > > > > > > > We have added a new feature to do just that in the development > > > branch, > > > > > > but it should be fairly trivial to do with existing releases of > > > > > > matplotlib. Just create a figure object and use its figtitle to > > hold > > > > > > the expression and then save the figure. > > > > > > > > > > It might be trivial but how to remove the axis/plot then and crop > > the > > > > > extend of the eps? > > > > > > > > > > I tried: > > > > > > > > > > plt.figure() > > > > > > > > > > > > > > > plt.title(r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > > > > fontsize=20) > > > > > plt.show() > > > > > > > > > > /j > > > > > > > > > > > > > > Use figtext instead. I did the following and it looked fine to me: > > > > > > > > plt.figure() > > > > plt.figtext(0.1, 0.5, > > > > > > > > > > r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > > > > fontsize=20) > > > > plt.show() > > > > > > > > > > > > > thats working nearly perfect, I would just need to crop the display > > extend > > > resp. the white space from the eps around...any option/idea? > > > > > > > > > /j > > > > > > > > Try setting bbox_inches='tight' in the call to savefig. With > > bbox_inches='tight', you can then specify the 'pad_inches' kwarg to > > indicate > > how much padding to put around the tight bounding box. This should work, > > however some older version of matplotlib might not check the figure text > > objects for calculating the tightest bounding box. > > Hej, > > I tried your suggestion like: > plt.figure() > plt.figtext(0.01, > 0.5,r'$F(x)=p*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}+(1-p)*\frac{1}{s1\sqrt{2\pi}}*e^{-\frac{1}{2}*(\frac{x-m}{s1})}$', > fontsize=26) > #plt.show() > plt.savefig("testplot.eps", bbox_inches='tight') > > but get following error: > plt.savefig("testplot.eps", bbox_inches='tight') > File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", > line 363, in savefig > return fig.savefig(*args, **kwargs) > File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", > line 1084, in savefig > self.canvas.print_figure(*args, **kwargs) > File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backend_bases.py", > line 1891, in print_figure > bbox_inches = self.figure.get_tightbbox(renderer) > File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", > line 1212, in get_tightbbox > _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) > File > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/transforms.py", > line 675, in union > assert(len(bboxes)) > AssertionError > > > For your information: > I work with python 2.6.6 and matplotlib 1.0.1 on Mac OS X 10.6.6 > > /j > > > There have been some bugs fixed with bbox_inches='tight', but I couldn't remember if they happened after or before the v1.0.1 release. My guess is that it happened after. I am glad the other function worked for you. Ben Root |