Difference between revisions of "Pgfplot"

From HCL
Jump to: navigation, search
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},width=\textwidth,height=7.4cm,
 +
xlabel=Number of processors,
 +
ylabel=Execution time ($10^3$ s),legend
 +
style={at={(.9,.9)}},ymin=0,ymax=8.8,mark size=1.5]
 +
%, ytick={1000,2000,3000,4000,5000,6000,7000,8000}]
 +
%,
 +
%xtick={0,5,10,15,20,30,50},ytick={1000,2000,4000,8000}]
 +
\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,yexpr=\thisrowno{2}/1000]{data};
 +
\legend{WSCOM$_{\text{pf}}$,WSCOM,list\_min};
 +
 +
\end{axis}\end{tikzpicture}
 +
</source>
 +
 +
<source lang="data">
 +
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>

Revision as of 12:48, 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},width=\textwidth,height=7.4cm,
xlabel=Number of processors,
ylabel=Execution time ($10^3$ s),legend
style={at={(.9,.9)}},ymin=0,ymax=8.8,mark size=1.5]
%, ytick={1000,2000,3000,4000,5000,6000,7000,8000}]
%,
%xtick={0,5,10,15,20,30,50},ytick={1000,2000,4000,8000}]
\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,yexpr=\thisrowno{2}/1000]{data};
\legend{WSCOM$_{\text{pf}}$,WSCOM,list\_min};

\end{axis}\end{tikzpicture}
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