{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

4
votes
1answer
327 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 ...
3
votes
1answer
1k 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. ...
7
votes
2answers
4k 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 ...
13
votes
1answer
1k 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 ...
7
votes
1answer
4k 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.
6
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
340 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
334 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 ...
13
votes
1answer
2k 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 ...
8
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 ...
4
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 ...
9
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 ...
13
votes
2answers
2k 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
465 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
618 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?
13
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
556 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 ...
22
votes
1answer
3k 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
826 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
308 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, ...
20
votes
2answers
2k 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 ...
17
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
10k 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
235 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
2k 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
506 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 ...
5
votes
2answers
7k 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
460 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} { ...
15
votes
1answer
3k 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
546 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
859 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
848 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
418 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
544 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
308 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 ...
16
votes
1answer
3k 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
875 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
435 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 ...