{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

5
votes
2answers
6k views

Externalize graphics when using pgfplots doesn't work (MiKTeX 2.9)

I'm having problems exporting my pgfplots figures to separate files using the externalize command. I get an error, the central point of which seems to be "Please verify that you have enabled system ...
2
votes
1answer
1k views

pgfplots and backgrounds library

When I use framed option from backgrounds tikz library for axis environment, this example works ok: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usepackage{pgfplots} ...
1
vote
1answer
772 views

Using \footnotesize in tikz node labels

I have used \footnotesize to scale labels before and it has produced the desired results. But am having problems when I pass this as part of the label to a macro. The following MWE compiles but not if ...
5
votes
2answers
1k views

How to use very large data sets with pgfplots w/o making pdf take a very long time to load?

I'm working with a very large data set - almost 120,000 observations - and I'm using pgfplots to make some plots. The process goes ok, especially with the use of the external library, but the pdf ...
11
votes
2answers
2k views

How to access \xmin, \xmax, \ymin, \ymax from within PGFplots axis environment

In the MWE example below I have the values specified twice, but would prefer not to have to do that. Furthermore, it is possible to allow PGFplots to automatically select these end points so I would ...
8
votes
1answer
2k views

Different scales on the same plot

I would like to know whether and how the pgfplots package can be used to produce a plot with two curves using different scales, like in the following example:
2
votes
1answer
2k views

Drawing Vertical Arrows in Coordinate System Using Pgfplot

I have a series of data plots, an example of which is depicted below, and I would like to draw a vertical line through a particular x-coordinate on each plot, so that the head of the arrow is is ...
4
votes
3answers
3k views

Change white-space border in pgfplot, or crop PDF figure?

I am toying a bit with the pgfplot way of presenting data. It makes pretty nice plots, but unfortunately it is not very economical with my space. This is a problem when using a multi-column layout. ...
4
votes
1answer
664 views

How to specify a name path for the axis in PGFplots

When I use the {axis} environment, the axis are drawn automatically so I am not able to specify a name for them? I would like to be able to compute intersections with the axis as in Intersections in ...
7
votes
1answer
535 views

Is there a way to clear paths previously defined with name path global in TikZ

In the solution to Intersections in PGFplots it was pointed out that each \addplot command was drawn in its own scope and using name path would not survive outside of that \addplot command. The ...
13
votes
1answer
2k views

Intersections in PGFplots

I can get intersections to work in TikZ, but not PGF plots. I defined a command to show the intersections to make sure that it is identical in both cases. Commenting out the \ShowIntersection line in ...
5
votes
2answers
1k views

Area between curves

I want to fill the area of a region R bounded by x=f(y), x=g(y), y=A and y=B. For example, R is bounded by x=0, x=2/y, y=1 and y=4.
4
votes
2answers
1k views

Which measurement units to use to shift labels in TikZ/PGFplot graphs

I often end up shifting labels on my TikZ/PGFplot graphs using, for example, xshift=1.0em, or yshift=1.0ex. Are these the correct units to be using to to the shifting? I don't think I should use ...
11
votes
1answer
2k views

Using Labels from a File in PGFplot

I am using LaTeX, TikZ and PGFplot in order to automatically generate several series of diagrams, one of which is comprised of bar charts. Each bar in each bar chart may have a unique label and height ...
7
votes
2answers
6k views

tikz legend in caption

I have adapted a piece of code that I found on the Q&A forum multiple legends in pgfplots as follows in order to include the legend of a drawing directly into the caption: EDIT 1 ...
1
vote
1answer
281 views

pgfplots: correlation for data values from file works, but with errors

maybe I do not to see the wood for the trees, but I'm always getting error messages for compiling the following pgf code, while the output looks like the way it should. Does anyone see whats wrong ...
7
votes
1answer
2k views

Abbreviated month names as tick labels in PGFplots

How can I modify the following example from PGFplots package to have the x-axis represent months and labelled as JAN, FEB, MAR etc.? \begin{tikzpicture} \begin{axis}[ smooth, ...
8
votes
5answers
2k views

How can I draw dirac deltas with arrow heads with pgfplots

I would like to draw this in pgfplots: I've tried this, but I can't figure out how to get the arrowheads. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} ...
2
votes
1answer
503 views

Matching Rotated \hyperref in arbitrarily rotated x-label in Pgfplots

Similar to this question: How to make pgfplots vertical labels have proper hyperref erence box? Except, that I am trying to get hyperref working with angled rotated x-axis labels: Got it working, ...
6
votes
1answer
2k views

Enlarge error bars in Pgfplots

Trust me, I've been trying everything I can to understand the error bars in pgfplots. What I want to do is increase the thickness/size of the error bars, so they are clearer on the graph. This ...
4
votes
1answer
348 views

pgfplots: “x stick” style

I am trying to reproduce the following example. The xbar and ybar options are not really what I am looking for since I am only interested in having horizontal lines as markers of points. Is there any ...
4
votes
1answer
2k views

Draw shifted plots from the same data

I need to draw a shifted plot from a data table (or a external file) without edit table coordinates. Using the shift={(x,y)} option works but x and y are not related to the axis coordinates s and f. ...
8
votes
3answers
7k views

Pgfplots: Replace x-axis numbering with labels on confidence interval plot?

Try as I might, I can't seem to replace the numbering on the x-axis with (arbitrary) labels. Here is a half-and-half, where the plot has been done in PGPPlots and I've added two of the x-ticks ...
15
votes
1answer
2k views

Smooth option sometimes produces incorrect arrow tips in PGFplots

It seems that the smooth option applied to lines sometimes effects the arrow tips and produces incorrect results. No problem with vertical lines, but any other seems to have a problem. Is this a ...
10
votes
1answer
6k views

Plot a function of a binary logarithm with TikZ

How do I plot a function of a binary logarithm with TikZ? Say that I want to plot f(x) = log_2 x.
7
votes
1answer
2k views

Insert space between axis and plot in pgfplots

I've done my first bar chart with pgfplots and it looks like this: As you can see the first and the last bar are not completely visible and things got even worse when I tried to add another plot. ...
4
votes
1answer
402 views

How to define a parameterized command to be consumable in \pgfmathdeclarefunction?

This is the solution to defining a piecewise function for pgfplots. However, I would like to be able to use a macro to define each of the pieces of the function. It is simple to do this if one is ...
9
votes
1answer
369 views

Why do 2 identical function definitions with different names produce two different plots?

In the code snippet below I would have expected both r(x) and s(x) to be the same line, but the output is two radically different lines as shown below. If there is a problem using the name r as a ...
15
votes
1answer
3k views

Defining a Piecewise Function for PGFplots

I want to define a piecewise function q(x), and attempted to adapt the solution to this question on using pgfmathdeclarefunction to create a unit pulse function, and this works fine. However, when I ...
9
votes
1answer
1k views

Pgfplots: plot graph inside table

I would like to plot a table with a graph inside it. I am trying to use this example as a guide. This is the current hand-constructed version. UPDATE: I don't have enough reputation to answer my ...
5
votes
1answer
1k views

pgfplots, ybar-plot: how to mark a missing value?

I'm very, very happy with pgfplots and using the ybar-plot-function to create a lot of diagrams. At the moment I wonders if it is possible to mark a missing value, for example with an asterisk. As you ...
10
votes
1answer
1k views

How to have linked axes on plots?

I plot infrared spectra in many reports and I display the energy units in two ways, wavenumbers $cm^{-1}$ on the bottom x-axis and wavelength (nm) on the upper x-axis. The relationship is ...
17
votes
2answers
3k views

inset plot with pgfplots

I am using pgfplots to plot some data I have, and I wanted to generate a large plot with another plot inside of it, showing a zoom on a region of the large plot. I have noticed that when you do ...
16
votes
1answer
2k views

PGFplot Axis Labels Detaching From Graph

Update: Aug 04, 2013 With the current version of TeXLive 2013, the second MWE below still exhibits the same behavior if the \todo[inline] is commented out after the first run. Furthermore, the ...
4
votes
2answers
503 views

PGFplot producing “noise” (incorrect graph)

Update: This has problems if the samples are one of these: {19,21,23,28,30,31,32,34,36,38,39}, so I think something else is going on. I can get this example to work fine if I reduce the number of ...
5
votes
1answer
2k views

Date plot using pgfplots with odd tick label

How do I make the time label in the following image appear as "10:00" (i.e. 10 o'clock) rather than the unexpected and unwelcome "09:60"? Here's the code that I am using: \documentclass{beamer} ...
3
votes
1answer
696 views

How to make pgfplots to center a text in a xticklabel

In pgfplots I've used the text width option in the definition of xticklabel style and I wonder how to center the labels text?
14
votes
1answer
2k views

Plotting an implicit function using pgfplots

What is the correct way to plot an implicit function using pgfplots? Consider the following example: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} ...
3
votes
1answer
598 views

How can I create an angled grid in a 2D PGFPlots plot?

Is it possible to make PGFPlots display 45° height lines in an axis? Basically, what I am looking for is a grid defined by y=-x + k*1000, k being a natural number. My numbers are rather large, e.g. y ...
25
votes
1answer
4k views

How can I adjust the horizontal spacing between legend entries in PGFPlots?

I am using legend columns=-1 to make a horizontal legend. However, the distance between the individual legend entries is too small for my taste. Is there a straightforward way to increase the ...
4
votes
1answer
941 views

Using Macro Defined Lists in TikZ/PGFplots

I want to be able to use a macro to specify a list (it is a constant list, i.e. will not change throughout the document) and use this macro rather than hard code the list contents in the TikZ/PGFplots ...
5
votes
1answer
342 views

Using \IfNoValueTF within a TikZ style specification.

In an answer to Flushing PGF commands and local variable Matthew had suggested using \IfNoValueTF within a TikZ \node specification to determine the text. This solution works great for me. However, ...
24
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 ...
19
votes
4answers
5k 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
13k 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
238 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
537 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
11k 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?