New pgf backend for LaTex?

Hello,

are there plan to implement a new backend for the latex proper use
which create the drawing comand in the pgf language? With this kind
of graphic creation I could overcome all the (font-) scaleing problems
I have when I want to include a mpl graphic in my latex document.

Even gnuplot has such an backend but I dont want to use it anymore :slight_smile:

By, Friedrich

I'm not familiar with pgf, could you provide some more information? What
problems do you have with font scaling, and what additional capabilities do
you think such an approach would offer?

Darren

路路路

On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote:

Hello,

are there plan to implement a new backend for the latex proper use
which create the drawing comand in the pgf language? With this kind
of graphic creation I could overcome all the (font-) scaleing problems
I have when I want to include a mpl graphic in my latex document.

> Hello,
>
> are there plan to implement a new backend for the latex proper use
> which create the drawing comand in the pgf language? With this kind
> of graphic creation I could overcome all the (font-) scaleing problems
> I have when I want to include a mpl graphic in my latex document.

I'm not familiar with pgf, could you provide some more information?

pgf is a tex-based graphic language similar to ps-tricks but also
for pdftex. There are very nice graphics:

聽聽http://www.ctan.org/get/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf

The basic drawing is like this (a cross)

\begin{tikzpicture}
聽聽\draw (-1.5,0) -- (1.5,0); % horizontal line
聽聽\draw (0,-1.5) -- (0,1.5); % vertical line
聽聽\draw (1,1) node{$y=x^2$}; % text label
\end{tikzpicture}

There also exsits makro pakages for (more ore less convinent) data plots
but then you dont have the nice python interface.

What problems do you have with font scaling, and what additional
capabilities do you think such an approach would offer?

I want that fonts in the mpl graphics have the same (or otherwise related)
proerties as the main-font in my latex document.

So, therefore I have to know all the font properties from my latex
document (\normalfont): type, family, size.

The next problem is that the standard size of the mpl graphic (8, 6) inches
is too big for my latex document (0.5\linewidth). Therefore I must scale
the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this
scaling the font in the mpl graphic are also scaled and I have no chance
adapeting the two fonts (mpl, latex) without manual iterations.

Ok, I could adjust the figsize but the last time I did it (long time ago)
there were other misplaced objects in the mpl graphic (I dont remember
exactly, sorry).

But if I had the whole mpl graphic as pgf commands there would be no
problem with the font stuff, scaleing and line widths. And may be you
could extend the mpl graphic with some tricky (and eye candy) pgf
extensions (ok I am also a beginner with the pgf language but its
realy powerfull).

BTW. In the same way I can create very nice ciruit schematic with
CircuitMacros

聽聽www.ece.uwaterloo.ca/~aplevich/Circuit_macros/html/examples.pdf
聽聽
I hope you could understand what I mean :slight_smile:

By, Friedrich

路路路

On Fri, May 23, 2008 at 10:51:05AM -0400, Darren Dale wrote:

On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote:

PGF is the LaTeX portable graphics format, which can be used
both with PDF production and DVI->PS production. It is
a very nice innovation for LaTeX users, especially via its
TikZ interface.

PGF users get the full power of LaTeX for typesetting on
their diagrams. This is great. For this reason, I often
write PGF/TikZ code by hand when my graphs are simple.

A PGF backend would be wonderful for LaTeX users who are
producing documents for final distribution.

All that said, I suspect the payoff to me personally would
be modest, as I am almost always producting documents for
later publication, at which point I generally need to
provide EPS or PDF figures.

If you are still interested, you may find the following to
be useful:
<URL:http://www.tug.org/pracjourn/2007-1/mertz/>

hth,
Alan Isaac

路路路

On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote:

are there plan to implement a new backend for the latex proper use
which create the drawing comand in the pgf language? With this kind
of graphic creation I could overcome all the (font-) scaleing problems
I have when I want to include a mpl graphic in my latex document.

On Fri, 23 May 2008, Darren Dale wrote:

I'm not familiar with pgf, could you provide some more information? What
problems do you have with font scaling, and what additional capabilities do
you think such an approach would offer?

> > Hello,
> >
> > are there plan to implement a new backend for the latex proper use
> > which create the drawing comand in the pgf language? With this kind
> > of graphic creation I could overcome all the (font-) scaleing problems
> > I have when I want to include a mpl graphic in my latex document.
>
> I'm not familiar with pgf, could you provide some more information?

pgf is a tex-based graphic language similar to ps-tricks but also
for pdftex. There are very nice graphics:

http://www.ctan.org/get/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf

The basic drawing is like this (a cross)

\begin{tikzpicture}
\draw (-1.5,0) -- (1.5,0); % horizontal line
\draw (0,-1.5) -- (0,1.5); % vertical line
\draw (1,1) node{$y=x^2$}; % text label
\end{tikzpicture}

There also exsits makro pakages for (more ore less convinent) data plots
but then you dont have the nice python interface.

> What problems do you have with font scaling, and what additional
> capabilities do you think such an approach would offer?

I want that fonts in the mpl graphics have the same (or otherwise related)
proerties as the main-font in my latex document.

I understand this desire. John Hunter came up with the idea of the current
latex support around the time that I was writing my dissertation. Like you
note below, we sometimes have to iterate to get just what we want, but I
think that is unavoidable. More below...

So, therefore I have to know all the font properties from my latex
document (\normalfont): type, family, size.

The next problem is that the standard size of the mpl graphic (8, 6) inches
is too big for my latex document (0.5\linewidth). Therefore I must scale
the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this
scaling the font in the mpl graphic are also scaled and I have no chance
adapeting the two fonts (mpl, latex) without manual iterations.

Ok, I could adjust the figsize but the last time I did it (long time ago)
there were other misplaced objects in the mpl graphic (I dont remember
exactly, sorry).

But if I had the whole mpl graphic as pgf commands there would be no
problem with the font stuff, scaleing and line widths. And may be you
could extend the mpl graphic with some tricky (and eye candy) pgf
extensions (ok I am also a beginner with the pgf language but its
realy powerfull).

Wouldn't this cause some problems with how the text is layed out on the
canvas? The way it works now, a title can be centered over the axes because
the extents of the text are known. If you allow the fonts and font sizes to
be dictated by the latex document, they will end up being positioned
incorrectly.

P.S. please be careful that your responses go to the userlist

路路路

On Friday 23 May 2008 11:30:03 am Friedrich Hagedorn wrote:

On Fri, May 23, 2008 at 10:51:05AM -0400, Darren Dale wrote:
> On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote:

The next problem is that the standard size of the mpl graphic (8, 6) inches
is too big for my latex document (0.5\linewidth). Therefore I must scale
the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this
scaling the font in the mpl graphic are also scaled and I have no chance
adapeting the two fonts (mpl, latex) without manual iterations.

Ok, I could adjust the figsize but the last time I did it (long time ago)
there were other misplaced objects in the mpl graphic (I dont remember
exactly, sorry).

I tried this now with (width = 7cm = 2.67in)

In [1]: figure(figsize=(2.67,2))
Out[1]: <matplotlib.figure.Figure object at 0x8c3b36c>

In [2]: subplot(111)
Out[2]: <matplotlib.axes.AxesSubplot object at 0x8c3b3ec>

and the problem is that the remaining (abolute) space of the margin
ist too small for the whole labeling (ticks and axis). But I dont
want to adjust all the default values every time a what a plot in
my latex document.

Wouldn't this cause some problems with how the text is layed out on
the canvas? The way it works now, a title can be centered over the axes
because the extents of the text are known. If you allow the fonts and
font sizes to be dictated by the latex document, they will end up being
positioned incorrectly.

Shortly: Yes this is a problem but pgf could solve it.

I dont know it exactly but if you do all the graphic stuff with pgf in
latex so you can adjust the text boxes in a various way in respect to
different points. E.g. baseline -left, -right, -center and so on. This is
explaind in the pgfmanual in section 53.3.3.

If I fly over the pgfmanual I get the impression that I could do
everything with it :slight_smile: But to do this its a hard work (for beginners).

Therefore I like to have the convinient pylab-interface to create pretty
standard plots for latex.

By, Friedrich

路路路

On Fri, May 23, 2008 at 05:30:02PM +0200, Friedrich Hagedorn wrote:
On Fri, May 23, 2008 at 12:00:03PM -0400, Darren Dale wrote:

I'll keep it in mind, but I have just committed myself to another mpl-related
project for the summer, so I dont think I will have time to look into this
for a while. But we love code submissions...

路路路

On Friday 23 May 2008 12:25:39 pm Friedrich Hagedorn wrote:

On Fri, May 23, 2008 at 05:30:02PM +0200, Friedrich Hagedorn wrote:
> The next problem is that the standard size of the mpl graphic (8, 6)
> inches is too big for my latex document (0.5\linewidth). Therefore I must
> scale the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But
> with this scaling the font in the mpl graphic are also scaled and I have
> no chance adapeting the two fonts (mpl, latex) without manual iterations.
>
> Ok, I could adjust the figsize but the last time I did it (long time ago)
> there were other misplaced objects in the mpl graphic (I dont remember
> exactly, sorry).

I tried this now with (width = 7cm = 2.67in)

In [1]: figure(figsize=(2.67,2))
Out[1]: <matplotlib.figure.Figure object at 0x8c3b36c>

In [2]: subplot(111)
Out[2]: <matplotlib.axes.AxesSubplot object at 0x8c3b3ec>

and the problem is that the remaining (abolute) space of the margin
ist too small for the whole labeling (ticks and axis). But I dont
want to adjust all the default values every time a what a plot in
my latex document.

On Fri, May 23, 2008 at 12:00:03PM -0400, Darren Dale wrote:
> Wouldn't this cause some problems with how the text is layed out on
> the canvas? The way it works now, a title can be centered over the axes
> because the extents of the text are known. If you allow the fonts and
> font sizes to be dictated by the latex document, they will end up being
> positioned incorrectly.

Shortly: Yes this is a problem but pgf could solve it.

I dont know it exactly but if you do all the graphic stuff with pgf in
latex so you can adjust the text boxes in a various way in respect to
different points. E.g. baseline -left, -right, -center and so on. This is
explaind in the pgfmanual in section 53.3.3.

If I fly over the pgfmanual I get the impression that I could do
everything with it :slight_smile: But to do this its a hard work (for beginners).

Therefore I like to have the convinient pylab-interface to create pretty
standard plots for latex.