{pgfplots} is a package for creating 2D and 3D plots of mathematical functions and numerical data, using the PGF graphics framework. For questions about the inbuilt plotting functionality of TikZ/PGF, use {tikz-pgf} instead.

learn more… | top users | synonyms

21
votes
2answers
3k views

PGFplots foreach equivalent to TikZ's with multiple variables separated by a slash

I like TikZ's capability to traverse multiple variables separated by a slash in the foreach (as in the example below). I am looking for something equivalent in PGFplots? I saw in the documentation ...
18
votes
4answers
4k views

Fill the area between two curves calculated by pgfplots

This is essentially the same question as fill the area between two curves when their coordinates are known. In that question, the curves were defined by known coordinates. I want to fill the area ...
12
votes
1answer
12k views

How to properly scale a TikZ/PGF picture which has a `\begin{axis}…\end{axis}`

Applying a scale option to a TikZ picture works great. It keeps the text the proper size and scales everything else. I would like to have the same behavior when using a \begin{axis}...\end{axis}. ...
4
votes
1answer
236 views

Determine if within a PGF axis environment

Is there an easy way to test whether a macro is called from within an PGF \begin{axis}...\end{axis} environment? One solution would be to define a new environment myself that sets a flag at ...
2
votes
1answer
3k views

usepgfplotslibrary - undefined control sequence

I have problem with following example code: %& --shell-escape --enable-write-18 \documentclass[a4paper,10pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{polski} ...
3
votes
2answers
529 views

pgfplots - lack of one bar

I want to make a chart with nine bars. As you can see they are in the code (0-8). Unfortunately it's making only eight bars. \documentclass[12pt]{report} \usepackage{polski} ...
3
votes
4answers
1k views

How do I align a pgfplots graph?

I'm trying to draw a graph with the associated table of data using pgfplots. It works great, but the graph itself isn't aligned with the table. This is what it looks like: I don't like the ...
6
votes
2answers
8k views

How to plot f(x)=sin(x), k(x)=cos(x) and u(x)=x² with TikZ

How can we plot the following three functions f(x) = sin(x) k(x) = cos(x) u(x) = x² for x ∈ [0,1] on a single plot with the help of TikZ?
1
vote
0answers
493 views

pgfplotsinvokeforeach using parameter [closed]

The following code works in the minimal example but not in my document \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \pgfplotsinvokeforeach{1,2,...,10} { ...
18
votes
1answer
4k views

How can I make my pgfplots ylabel multiline?

My pgfplots ylabel text is too long and looks strange. Can I make it multiline?
12
votes
3answers
2k views

Use macro as coordinate in pgfplots plot

I'm trying to come up with a solution to the question How to maintain consistency with TikZ and Pgfplots?. Essentially, what is needed is a way to save a coordinate as a macro (or a global key, ...
4
votes
1answer
588 views

How can I prevent pgfplots from rendering lines incorrectly when I use “no markers”?

I plot tabular data wherein none of the y-values of the data go above 1.0. In the resulting plot, however, there are a couple of peaks that go beyond 1.0, giving a false impression about those data ...
11
votes
2answers
2k views

How to maintain consistency with TikZ and Pgfplots?

I would like to maintain some consistency between TikZ and PGFplots, and have run into numerous difficulties. Here is an example of two of them: I would like to be able to use something similar to ...
8
votes
1answer
2k views

Using ifthenelse in pgfmath

Following questions on constructing functions on the forum, I tried to build some myself. I can't seem to get the ifthenelse function in TikZ/PGF to work. Here is an example: ...
6
votes
5answers
3k views

How do I use pgfmathdeclarefunction to create define a new pgf function?

I'd like to define new function for pgf so I can use it in pgfplots. I'm trying to create a unit pulse function p(x) which has a value of 1 from x=0 to x=1, and 0 elsewhere. I read the pgf manual on ...
3
votes
1answer
992 views

Documentation for pgfplots expressions?

Is there documentation for which functions work as pgfplots expressions (like sin, cos, exp, etc.) The pgfplots documentation doesn't seem to say anything on what you can/can't use.
6
votes
1answer
927 views

Pointing from Data in a pgfplotstable to a pgfplot

Are there PGF coordinates available for elements in a pgfplots table? Groupplots allow to address plots via (group c2r1.center) (column 2, row1). \pgfplotstabletypeset[col sep=&,row sep=\\,sci ...
7
votes
1answer
3k views

Scatterplot with pgfplots

I want a 2x2 scatterplot matrix of the data in the file scatter.dat: 0.5334437 0.4824717 0.6848940 0.6865826 0.5818373 0.6335347 0.5465202 0.5290712 The following code works: ...
4
votes
1answer
441 views

Accessing the n-th coordinates of a plot

\begin{tikzpicture} \begin{axis} \addplot coordinates { (1,1) (2,4) (3,9) (4,16) }; \draw (axis cs:0,0) -- (axis cs:3,9); \end{axis} \end{tikzpicture} I can easily draw a line ...
10
votes
1answer
581 views

Tabs in output file written by xelatex and pdflatex are different

I'm trying out pgfplots with gnuplot to generate the data. This works by having pgfplots write some stuff to an external file, run gnuplot on the file, and then use the generated data to plot the ...
3
votes
2answers
312 views

Use \def without including the square bracktes with pgfplot?

I would like to define a line style to use in my pictures. But would still like to retain the flexibility to be able to tweak these if needed in the actual picture, as in the third picture ...
18
votes
1answer
4k views

pgfplots: prevent single plot from being listed in legend

In order to fill the area between two complex curves I use tables and the vertcat command (see Fill between two curves in pgfplots.). Now I don't want the plotted area to appear in my legend, just ...
10
votes
2answers
2k views

tikz/pgfplots advanced z-order axis/grid

Is it possible to have both the axis on top and the grid on the very bottom (or somewhere in between some other planes/lines/...) of a plot? Example figure with axis on top=true but the grid on top ...
7
votes
1answer
2k views

tikz spy library with pgfplots: opacity and grid

When I use the tikz.spy library in order to magnify a part of my pgfplots plot with the use of grids, there are both the original grid and the magnified grid in the magnified area. screenshot: . a ...
3
votes
3answers
1k views

How to plot a third variable (z) on pgfplot as a color gradient

I'm trying to use pgfplots to create a 2D plot with 3 variables, the third one being plotted as a color gradient. \begin{tikzpicture}[scale=0.75] \begin{axis}[xlabel=Selta,ylabel={Hitastig ...
6
votes
1answer
1k views

grouping options problem in pgfplots.groupplots

i have a problem with the grouping options of pgfplots.groupplots. besides the labels i have also units defined. with the option xlabels at=edge bottom only the label but not the unit is moved to the ...
6
votes
4answers
958 views

How to create pgfplots cycle list from a table?

I know that a pgfplots cycle list can be created with \pgfplotscreateplotcyclelist. However, the examples given in the pgfplots manual explicitly list all the items. I am wondering if it is possible ...
4
votes
1answer
451 views

Pgfplots jump mark error when plotting a floor function

For some weird reason the following code gives me the wrong plot \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot+[jump mark left,samples ...
2
votes
2answers
826 views

pgfplots: setlength inside foreach

I have the following code, where the size of the cube marks is set to \x inside a foreach loop: \begin{tikzpicture} \begin{axis}[axis lines=none] \newlength{\mylen} \foreach \x in {1,2,...,10} ...
7
votes
1answer
1k views

Extract the x/y part from a coordinate in pgfplots

How can I extract only the x or y part of a predefined coordinate? For instance, let's say we have \coordinate (A) at (1,2); And I want to use the x part of (A) like this \draw (x of A,3)--(0,0);
7
votes
2answers
1k views

Use a variable as a coordinate in pgfplots

I have the following code: \begin{tikzpicture} \begin{axis}[domain=0:40] \addplot {x}; \def\a{\pgfmathparse{1+1}\pgfmathresult} %\draw (\a,20)--(axis cs:20,0); \node at (axis ...
2
votes
1answer
599 views

how to use \insert{_file_} to include tikz \draw command?

I'm using Stata to run some simultions, and my data change every time I run my do file. My data have a discontinuity that changes with each run and I'd like a curly brace that reflects the size of ...
14
votes
2answers
4k views

Dimension too large while plotting with pgfplots

I have the following pgfplots code: \begin{tikzpicture} \begin{axis}[domain=-8:2] \foreach \i in {-10,-9.8,...,10} {\addplot+[smooth] {-x/\i+\i};}% \end{axis} \end{tikzpicture} I need several ...
7
votes
1answer
681 views

How can one predict pgfplots memory overload?

I have some legitimate data sets that overload the memory available to TeX. Of course the recommended step is to cut the number of data points instead of changing the "main memory size". (In my case ...
1
vote
1answer
1k views

\pgfresetboundingbox is undefined control sequence?

I'm sure this question has a simple answer that I'm missing: I'm trying to use pgfplots to put two graphs right next to each other with no space in between. I thought I could do this by using the ...
6
votes
1answer
2k views

pgfplots: Multiple (shifted) stacked plots in one diagram

How can I get multiple stacked plots (ybar stacked, stack plots=y) in one diagram, such that there are multiple stacked bars for the same x-coordinate, each slightly shifted? Is there a way to reset ...
4
votes
2answers
2k views

How to make pgfplots vertical labels have proper hyperref erence box?

PGFPlots and hyperref don't seem to play well together for vertical text. For example, the ylabel (which is vertical) shows its hyperref box in the middle of nowhere instead of at the position and ...
15
votes
1answer
3k views

Declare nodes in pgfplots as overlays

The Background In pgfplots, it is possible to make plot elements such as axis labels, ticks and legends overlay, which means they will not be considered when determining the bounding box of the plot. ...
5
votes
1answer
576 views

Grid Z-order in PGFPlots

How can I go about putting a grid in front of a bar chart in PGFPlots, preferably as automagically as possible? Ed Tufte demonstrates a rather appealing way of drawing bar charts in The Visual Display ...
4
votes
1answer
1k views

Accessing individual table elements with pgfplots?

I want to create a plot using a non-standard plot-style that I don't see in the pgfplots manual. It would be nice if I could take advantage of the \pgfplotstableread function and then somehow loop ...
5
votes
3answers
1k views

Incorrect plot using Pgfplots

I'm trying to plot a function with pgfplots for LaTeX. Unfortunately, pgfplots plots the function incorrectly. Here is the LaTeX code I use: \begin{figure}[H] \centering \begin{tikzpicture} ...
2
votes
0answers
176 views

Incorrect plot with pgfplots and LaTeX [duplicate]

Possible Duplicate: Incorrect plot using Pgfplots I'm trying to plot a function with pgfplots for LaTeX. Unfortunately, pgfplots plots the function incorrectly. Here is the LaTeX code I ...
8
votes
2answers
1k views

Using reference with externalized pgfplot figure

I am currently writing a document with a lot of plots. I draw them with pgfplots. which uses a lot of ressources. To manage that, I use the externalization feature of TikZ. In the file myarticle.tex, ...
35
votes
2answers
10k views

Label plots in pgfplots without entering coordinates manually

I like to label my plots directly, i.e. without using a legend, but instead using a pin node. So far, I have added the labels with manually specified coordinates, which means trial-and-error for data ...
10
votes
1answer
1k views

Make pgfplots typeset axis units as reciprocals using siunitx

pgfplots has a library units that allows to typeset units in axis labels provided through x unit=<unit>. Through the key \pgfplotsset{unit code/.code={\si{#1}}}, it can be made to typeset the ...
3
votes
1answer
1k views

Can't replicate this graph using TikZ

I'm having trouble replicating this graph I know it's silly to do a graph with so little info, but my teacher demands it.. go figure... I can't seem to make the bars stick together. It's my first ...
35
votes
1answer
9k views

Bell Curve/Gaussian Function/Normal Distribution in TikZ/PGF

Can anyone tell me how to plot a gaussian function/bell curve using TikZ/PGF? I'm basically looking to implement something like PSTricks's \psGauss command.
11
votes
1answer
3k views

Trend line or line of best fit in pgfplots

Is there an "out of the box" way to automatically draw the trend line in pgfplots? Below follows a basic illustration of a scatter graph with a line of best fit:
4
votes
1answer
2k views

Maths expression in coordinates for a bar chart

I am using pgfplots to create a bar chart, with the x-axis representing different categories. Using symbolic x coords I can specify the labels for the categories. However, I am unable to use a ...
4
votes
1answer
301 views

Dropped spines in pgfplot

How can I achieve something similar to the "dropped spines" example below using pgfplots?