Math & ScienceFormat Specifiers in Gnuplot Terminal 'epslatex'

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
mariaXY
Posts: 9
Joined: Wed Jul 06, 2011 11:00 am

Format Specifiers in Gnuplot Terminal 'epslatex'

Post by mariaXY »

Hi,

I am using epslatex to create a nice plots for my thesis. But I have a problem. I give the following instructions to create a plot:

Code: Select all

set terminal epslatex color
set logscale y
set format y "10^{%T}"
plot 'data.dat' w l lw 3 not
set output 'figure.tex'
replot
set output
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I put the output in my main latex code as following:

Code: Select all

Code, edit and compile here:
\begin{figure}[b!]
\begin{center}
\resizebox{4in}{!}
{
\input{figure}
}
\captionsetup{font=small, labelfont=bf, labelsep=period}
\caption[Small caption]{LARGE CAPTION}
\label{figure}
\end{center}
\end{figure}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
When I compile the main latex code, I got a error, latex complain about the \gplbacktext. I realized that the error es due to the instruction set format y "10^{%T}" when I create the plot. In the figure.tex file I obtain:

Code: Select all

\put(1606,704){\makebox(0,0)[r]{\strut{}10^{-5}}}%
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Then, I change the code to:

Code: Select all

\put(1606,704){\makebox(0,0)[r]{\strut{}$10^{-5}$}}%
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And it works OK. The problem is, that the output figure in the main pdf file looks smaller than other plots that I have with out set format y "10^{%T}".

I understand that the symbol % is a special character in latex, but I don't know how to solve this shrinking in the image and make the plots without change the code every time for all the plots...

I appreciate very much if someone can help me with this problem.

Thanks in advance.

Maria
Last edited by localghost on Tue Sep 13, 2011 6:41 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Format Specifiers in Gnuplot Terminal 'epslatex'

Post by localghost »

A much smarter way for nice plots would be to use pgfplots (based on pgf/tikZ) or pst-plot (based on PSTricks). Then problems like this would not arise.

If you insist doing your plots with Gnuplot, take a look at the gnuplottex package for better control of scripts within your document and some other threads for possible solutions [1-3]. You should find other appropriate solutions by a forum search.

[1] View topic: Gnuplot LaTeX Output
[2] View topic: Axis Labels of EPS File missing?
[3] View topic: Math formatting in Gnuplot Graph


Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Format Specifiers in Gnuplot Terminal 'epslatex'

Post by shadgrind »

mariaXY wrote:I realized that the error es due to the instruction set format y "10^{%T}" when I create the plot.
In gnuplot use this instead for your format command:

Code: Select all

set format y '$10^{%T}$'
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
As far as the image shrinking, you can make it bigger (e.g. 1.5 times bigger) in LaTeX like this:

Code: Select all

\scalebox{1.5}{\input{figure}}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
mariaXY
Posts: 9
Joined: Wed Jul 06, 2011 11:00 am

Format Specifiers in Gnuplot Terminal 'epslatex'

Post by mariaXY »

Hi,

Thanks a lot for your replies!

Code: Select all

set format y '$10^{%T}$'
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
works perfectly!

But the problem with the images is no solved with \scalebox, since the problem is the following. I attach a example of some figures. The one that I obtain with the code above is the first one. And, as you can see the size in the y-axis is fine, but the size in the x-axis not, in comparison with the second and third one. I want all my plots to have the same size. The second plot is without using set format, but it has long numbers. And the third one is a normal plot. Apparently more numbers on the y-axis shrink the plot on the x-axis... I would like to have my plots as the third plot. I mean, my values are 10^N, they shouldn't change to much (I guess)...

Thanks in advance (again!) ;)

Maria
Attachments
graphs.jpg
graphs.jpg (63.54 KiB) Viewed 12354 times
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Re: Format Specifiers in Gnuplot Terminal 'epslatex'

Post by shadgrind »

OK, I see what the size issue is now. The problem is that because gnuplot is making the vertical axis labels the string $10^{%T}$ (which is 9 characters), gnuplot has to leave enough room for those 9 characters to the left of the vertical axis when creating the plot. Of course when LaTeX processes that plot, those 9-character strings will get replaced by normal exponents 10^x (i.e. just 2 characters and a superscript). So this leaves some blank space of about 6 characters to the left of the vertical axis when the plot is typeset, which forces the x-axis to become about 6 characters smaller (so that the original 9-character labels don't overlap the vertical axis) when gnuplot creates the plot.

Interesting problem! The only way I see to fix this is by somehow telling gnuplot to make the x-axis a fixed size. I don't see how to do that; the gnuplot documentation seems to only show a way of setting relative sizes for the axes. There may be a way, but it's a gnuplot-specific (and not LaTeX-specific) issue. In this particular case, localghost is probably right that TikZ may be a better way of doing all this, though it will likely require more work on your part.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
mariaXY
Posts: 9
Joined: Wed Jul 06, 2011 11:00 am

Re: Format Specifiers in Gnuplot Terminal 'epslatex'

Post by mariaXY »

Anyway, thanks a lot shadgrind... I'll try to find the solution, and if I find it, I'll post it here...

Thanks again!!

Maria
jcaus
Posts: 1
Joined: Thu Aug 25, 2011 8:55 am

Format Specifiers in Gnuplot Terminal 'epslatex'

Post by jcaus »

Hey!

had this problem myself and just solved it, although it is a little bit messy. Just do what you're doing, then if you go into your .tex document generated by gnuplot you will find something like:

\put(440,2740){\rotatebox{90}{\makebox(0,0){\strut{}Your y-axis title}}}%

The \put(x,y) command tells tex where to put your y-axis title. So just change your x number to move it to the right. \put(1040,2740) looks good for me.

Hope this helps.

J
pizzocaro
Posts: 13
Joined: Mon Jun 14, 2010 2:26 pm

Format Specifiers in Gnuplot Terminal 'epslatex'

Post by pizzocaro »

Hi all,

I have used the epslatex terminal for my plot for some times now, since in my opinion can produce very high quality pictures. It can be tricky to use, for example because of the problem pointed out by shadgrind.

I am looking forward to use tikz for my plot instead, but for the time being I am quite happy with epslatex.

To get all the plot of the same size you can fix the margin (strongly suggested when using epslatex!), for example:

Code: Select all

set term epslatex color size 3.375,2.25
set lmargin at screen 0.18
set rmargin at screen 0.95
set bmargin at screen 0.15
set tmargin at screen 0.95
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I strongly suggest to fix the size of the figure to match the final desired result rather than using scalebox in latex (the default dimensions are 5 inches x 3.5 inches if I recall correctly).
The following four commands set the positions of the left, right, bottom and top margin of the plot area.
The keyword `at screen` indicates that the margin is specified as a fraction of the full figure.

At this point you should start tweaking at hand the position of the labels, that probably need some offsets, for example:

Code: Select all

set xlabel offset 0,.75
set ylabel offset 6.4,0
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The first command moves the xlabel slightly up, while the ylabel needs to be strongly moved to the right. Your values can vary, I usually set them by trial and error.

Hope this helps,

Marco
mariaXY
Posts: 9
Joined: Wed Jul 06, 2011 11:00 am

Format Specifiers in Gnuplot Terminal 'epslatex'

Post by mariaXY »

Hi Marco, Hi jcaus,

Thanks a lot for your replies. I manage to solve this problem in the same way as Marco suggest. Then the problem is solved. Just a comment for Marco: the position of the label can also be changed in the .tex file, as jcaus suggested, instead of trial and error just modify the line in the .tex file for the label:

\put(0,2739){\rotatebox{90}{\makebox(0,0){\strut{} LABEL}}}


change the \put(X,Y) coordinate, I think inside this file you have a better idea of where exactly put your label.

Thanks!

Maria
Post Reply