Use a powerful pgfplots drawing package in latex __latex

Source: Internet
Author: User


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

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

\addplot[color=red]{exp (x)};
%here ends the Furst plot
\hskip 5pt
%here begins the 3d plot
\begin{ Tikzpicture}
{exp (-x^2-y^2) *x};

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:


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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.