Http://www.sharelatex.com/learn/Pgfplots_package
Pgfplots Package
The Pgfplots package is a powerful tool, based in TikZ, dedicated to create scientific graphs.
Contents [Hide] 1 Introduction 2 the document Preamble 3 2D plots 3.1 plotting mathematical expressions 3.2 plotting from data 3.3 Scatter plots 3.4 Bar graphs 4 3D plots 4.1 plotting mathematical expressions 4.2 contour plots 4.3 plotting a surface fr Om Data 4.4 Parametric Plot 5 Reference guide 6 Further Reading |
Introduction
Pgfplots is a visualization tool to make simpler the inclusion of plots in your documents. The basic idea is this you provide the input Data/formula and Pgfplots does the rest.
pgfplots Example
\begin{tikzpicture}
\begin{axis}
\addplot[color=red]{exp (x)};
\end{axis}
\end{tikzpicture}
%here ends the Furst plot
\hskip 5pt
%here begins the 3d plot
\begin{ Tikzpicture}
\begin{axis}
\addplot3[
surf,
]
{exp (-x^2-y^2) *x};
\end{axis}
\end{tikzpicture}
Output
Since Pgfplot is based on TikZ the plot must to be inside a tikzpicture environment. Then the Environment Declaration \begin{axis},\end{axis} 'll set the right scaling for the plot, check the Reference GUID E for the other axis environments.
To add an actual plot, the command \addplot[color=red]{log (x)}; is used. Inside the squared brackets Some options can is passed, in this case we set the colour of the plot to red; The squared brackets are mandatory, if no options are passed a leave space blank between. Inside the curly brackets the function to plot. is important to remember the This command must end with Asemicolon;.
To put a second plot next to the one declare a new tikzpicture environment. Don't insert a new line, but a small blank gap, in this case Hskip 10pt would insert a 10pt-wide blank space.
The rest of the syntax is the same, except for the \ADDPLOT3 [Surf,]{exp (-x^2-y^2) *x};. This would add a 3dplot, and the optionsurf inside squared brackets declares that it ' s a surface plot. The function to plot must is placed inside curly brackets. Again, don ' t forget to put a semicolon; At the end of the command.
Note:it ' s recommended as a good practice to indent the Code-see the second plot into the example Above-and to add a COM Ma, at the ' end ' of each option passed to \addplot. This way the "code is" more readable and are easier to add further options if needed.
Open An example of the Pgfplots package in Sharelatex the document preamble
To include Pgfplots in your document are very easy, add the next line to your preamble and that ' s it:
\usepackage{pgfplots}
Some additional tweaking for this package can is made in the preamble. To change the size of all plot and also guarantee compatibility backwards (recommended) Add the next line: