Difference between revisions of "Pgfplot"

From HCL
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
  - the picture text has the same font as the rest of the document
 
  - the picture text has the same font as the rest of the document
  
--code--
+
=Preambule=
 +
<source lang="latex">
 
\usepackage{tikz}
 
\usepackage{tikz}
 
\usepackage{pgfplots}
 
\usepackage{pgfplots}
 +
</source>
 +
 +
=example=
 +
 +
<source lang="latex">
 +
\begin{tikzpicture}[transform shape,scale=0.9]
 +
\begin{axis}[
 +
                  ylabel style={yshift=-15pt}, % place of the ylabel
 +
                  width=\textwidth,height=7.4cm, %size of the picture
 +
                  xlabel=Number of processors,
 +
                  ylabel=Execution time ($10^3$ s),
 +
                  legend style={at={(.9,.9)}}, % place of the legend
 +
                  ymin=0,  ymax=8.8, % range for the y axe
 +
                  mark size=1.5 % size of the points
 +
                  ]
 +
\addplot+[] table[header=false,x index=0,y expr=\thisrowno{2}/1000]{data};
 +
\addplot+[] table[header=false,x index=0,y expr=\thisrowno{2}/1000]{data};
 +
\addplot+[] table[header=false,x index=0,y expr=\thisrowno{2}/1000]{data};
 +
 +
\legend{WSCOM$_{\text{pf}}$,WSCOM,list\_min};
 +
 +
\end{axis}\end{tikzpicture}
 +
 +
</source>
 +
 +
 +
a part of the file "data" is shown just after:
 +
 +
 +
<source lang="text">
 +
1  list_min 8241.04532500001 0.592721444672621 400
 +
2  list_min 4276.264 0.541485563775196 400
 +
3  list_min 2840.83145 0.240012784271948 400
 +
4  list_min 2171.53825 0.204766932333766 400
 +
5  list_min 1771.9397 0.187049380812677 400
 +
</source>

Latest revision as of 11:53, 9 May 2012

PgfPlot is a package which let you do the same things as gnuplot but directly inside your latex file. And this has a lot of advantages:

- no additional file
- no conversion from eps or ps or png to the pdf
- the quality is really improved
- the picture text has the same font as the rest of the document

Preambule

\usepackage{tikz}
\usepackage{pgfplots}

example

\begin{tikzpicture}[transform shape,scale=0.9]
\begin{axis}[ 
                   ylabel style={yshift=-15pt}, % place of the ylabel
                  width=\textwidth,height=7.4cm, %size of the picture
                  xlabel=Number of processors, 
                  ylabel=Execution time ($10^3$ s),
                  legend style={at={(.9,.9)}}, % place of the legend
                  ymin=0,   ymax=8.8, % range for the y axe
                  mark size=1.5 % size of the points
                  ]
\addplot+[] table[header=false,x index=0,y expr=\thisrowno{2}/1000]{data};
\addplot+[] table[header=false,x index=0,y expr=\thisrowno{2}/1000]{data};
\addplot+[] table[header=false,x index=0,y expr=\thisrowno{2}/1000]{data};

\legend{WSCOM$_{\text{pf}}$,WSCOM,list\_min};

\end{axis}\end{tikzpicture}


a part of the file "data" is shown just after:


1  list_min 8241.04532500001 0.592721444672621 400
2  list_min 4276.264 0.541485563775196 400
3  list_min 2840.83145 0.240012784271948 400
4  list_min 2171.53825 0.204766932333766 400
5  list_min 1771.9397 0.187049380812677 400