How to add legend in LaTeX?

How to add legend in LaTeX?

Add a legend by adding \legend{function 1, function 2} after the addplot commands. Hint: If your legend covers up an important part of your plot, add legend pos=north/south east/west to the axis parameters to move it. For example, to move the legend to the upper left use legend pos=north west .

How to add plot to LaTeX?

To add an actual plot, the command \addplot[color=red]{log(x)}; is used. Inside the square brackets, […] , some options can be passed in; here, we set the color of the plot to red .

How to plot straight line in LaTeX?

One of the simplest and most commonly used commands in TikZ is the \draw command. To draw a straight line we use this command, then we enter a starting co-ordinate, followed by two dashes before the ending co-ordinate. We then finish the statement by closing it with a semicolon.

How to use the pgfplots package in your document?

To use the pgfplots package in your document add following line to your preamble: You also can configure the behaviour of pgfplots in the document preamble. For example, to change the size of each plot and guarantee backwards compatibility (recommended) add the next line:

How to create a pgfplots plot in overleaf?

Open this pgfplots example in Overleaf. The following image shows the result produced by the code above: Because pgfplots is based on tikz the plot must be inside a tikzpicture environment. Then the environment declaration \\begin {axis}, \\end {axis} will set the correct scaling for the plot—check the Reference guide for other axis environments.

Where do you put square brackets in pgfplots?

The square brackets are mandatory, if no options are passed leave a blank space between them. Inside the curly brackets you put the function to plot. Is important to remember that this command must end with a semicolon (;). To put a second plot next to the first one declare a new tikzpicture environment.

Which is the last point in a pgfplot?

By using restrict y to domain=-10:10 (the same values as ymin and ymax) pgfplots discards any points that are not within that interval. Therefore, the last point within the interval will always be pos=1 and nodes can be placed easily like so: