On Tue, May 17, 2011 at 2:58 AM, Johannes Radinger <jradin...@gmx.at> wrote:

>
> -------- Original-Nachricht --------
> > Datum: Mon, 16 May 2011 11:36:18 -0500
> > Von: Benjamin Root <ben.r...@ou.edu>
> > An: Johannes Radinger <jradin...@gmx.at>
> > CC: matplotlib-users@lists.sourceforge.net
> > Betreff: Re: [Matplotlib-users] use matplotlib to produce mathathematical
> expression only
>
> > On Mon, May 16, 2011 at 11:22 AM, Johannes Radinger
> > <jradin...@gmx.at>wrote:
> >
> > >
> > > -------- Original-Nachricht --------
> > > > Datum: Mon, 16 May 2011 10:59:34 -0500
> > > > Von: Benjamin Root <ben.r...@ou.edu>
> > > > An: Johannes Radinger <jradin...@gmx.at>
> > > > CC: matplotlib-users@lists.sourceforge.net
> > > > Betreff: Re: [Matplotlib-users] use matplotlib to produce
> > mathathematical
> > > expression only
> > >
> > > > On Mon, May 16, 2011 at 10:21 AM, Johannes Radinger
> > > > <jradin...@gmx.at>wrote:
> > > >
> > > > >
> > > > > -------- Original-Nachricht --------
> > > > > > Datum: Mon, 16 May 2011 09:49:24 -0500
> > > > > > Von: Benjamin Root <ben.r...@ou.edu>
> > > > > > An: "matplotlib-users@lists.sourceforge.net" <
> > > > > matplotlib-users@lists.sourceforge.net>
> > > > > > Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to
> > > produce
> > > > >      mathathematical expression only
> > > > >
> > > > > > On Monday, May 16, 2011, Johannes Radinger <jradin...@gmx.at>
> > wrote:
> > > > > > >
> > > > > > > -------- Original-Nachricht --------
> > > > > > >> Datum: Mon, 16 May 2011 08:28:49 -0500
> > > > > > >> Von: Robert Kern <robert.k...@gmail.com>
> > > > > > >> An: SciPy Users List <scipy-u...@scipy.org>
> > > > > > >> CC: matplotlib-users@lists.sourceforge.net
> > > > > > >> Betreff: Re: [Matplotlib-users] [SciPy-User] use matplotlib to
> > > > produce
> > > > > >        mathathematical expression only
> > > > > > >
> > > > > > >> On Mon, May 16, 2011 at 08:21, Johannes Radinger <
> > > jradin...@gmx.at>
> > > > > > 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
> > > > > > >> Matplotlib-users@lists.sourceforge.net
> > > > > > >> 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
> > > > > > > scipy-u...@scipy.org
> > > > > > > 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
------------------------------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to