{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

248
votes
2answers
29k views

Create xkcd style diagram in TeX

The unique style of the diagrams at xkcd has an informative but nice hand-drawn touch. I guess they are actually drawn by hand but just recently on our partner site for Mathematica someone asked how ...
64
votes
4answers
26k views

How to expand TeX's “main memory size”? (pgfplots memory overload)

I'm compiling one pretty simple LaTeX file with few dozen of pgfplots. Now, I can compile part by part, but am unable to compile it all at once. I really need good precision for all those plots (noise ...
58
votes
6answers
3k views

Filling specified area by random dots in TikZ

I want to reproduce the following diagram in Tikz. LaTeX code of my MWE is below: \documentclass[tikz]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \draw [-latex, ...
48
votes
4answers
8k views

3-dimensional histogram in pgfplots

I have a simple 3d histogram which I want to import into pgfplots, e.g. using matlab2tikz or by hand. PGFplots does not offer 3d histograms. Is there an easy way to do this?
42
votes
4answers
13k views

pgfplots: how can I scale to text width?

This question led to a new package: tikzscale When I try to scale a plot with: width=\textwidth there is some horizontal space between the start/end of the plot and the start/end of the ...
37
votes
3answers
3k views

Is there a package that provides graphing in the style of Ed Tufte?

I have recently started using the tufte-latex package for various science writing and, while I love the package generally, am dismayed that it does not include the ability to produce graphics (charts, ...
37
votes
2answers
4k views

Axis break in pgfplots

Is there an easy way to 'break' the axis in a pgfplots environment? What I'm talking about is something like this Any minimal plot will do as an example...for example \documentclass{minimal} ...
37
votes
1answer
10k 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.
37
votes
1answer
3k views

Plotting several 2d functions in a 3d graph

I am trying to reproduce a similar figure to the following one. My first guess was to use pgfplots but I didn't find any example that I could use as a starting point. At the moment I am unsure if ...
37
votes
2answers
12k 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 ...
36
votes
3answers
12k views

Pgfplots: how to fill the area under a curve with oblique lines (hatching) as a pattern?

I want to hatch the area under a curve (graph of a function) with oblique lines on an interval (to illustrate the function's integral on that interval). This can be done elegantly in gnuplot... ...
36
votes
3answers
3k views

Replicate the Fourier transform time-frequency domains correspondence illustration using TikZ

The following time-frequency correspondence illustration is in the wikipedia entry of the Fourier transform. Also a gif animation version (if the animation doesn't show, please open the following ...
33
votes
2answers
5k views

What is the clearest way to graph a piecewise function?

I have a function defined as: How can I graph that using functions instead of coordinates? I'm currently working with pgfplots but I'm open to something else if it's better.
32
votes
3answers
1k views

Tufte like axis with pgfplots

How to achieve this kind of axis with pgfplot ? Image taken from Szymon Beczkowski's awesome PhD thesis design (thesis link) I may provide you with some data to play with. ...
32
votes
2answers
4k views

Drawing heatmaps using TikZ

Introduction I want to create a heatmap using TikZ. You can see the basic idea in the picture below: I basically have a table of values and each value is assigned a color. The picture is the result ...
31
votes
2answers
7k views

How can I add a zero line to a plot?

I frequently need to draw a horizontal or vertical line passing through the axis origin that spans the entire width or height of my plot area. I don't want to use axis lines=middle, because the tick ...
31
votes
2answers
13k views

number format in pgfplots axis

How can I change the type of the decimal/thousand separator from the american one to the european one? More precisely, I want: "1000" to be written as is, instead of "1,000" "0,1" instead of "0.1" ...
30
votes
4answers
2k views

Draw somewhat random function

I am trying to reconstruct this image here I am not very happy with the code, as it uses hacking and adding white boxes and alike. My problem is now how do I draw the somewhat arbitary function in ...
30
votes
2answers
2k views

How to plot a lattice of points on the surface of a torus?

I am doing a report on the Ising model, without going into the complex details of the model, in its two-dimensional form it involves a lattice of points. Which, when periodic boundary conditions ...
29
votes
5answers
3k views

How to draw the region of inequality?

Everyone, I would like to draw the region \begin{align*} x_1 + x_2 &\ge 3 \\ 2x_1 - x_2 &\le 5 \\ -x_1 + 2x_2 &\le 3 \end{align*} Here is my code to draw the region of inequality: ...
29
votes
1answer
924 views

Polar histograms

I recently stumbled upon this post, that explains how to make polar histogramms with R. An improved version of R-package can be found here. Even though it looks unfamiliar, the result of is quite nice ...
27
votes
3answers
2k views

Is there an easy way of using line thickness as error indicator in a plot?

I have several curves/datasets (obtained from Monte Carlo simulations) with x-dependent y errors I would like to plot with the errors somehow indicated. Since each curve consists of quite a large ...
27
votes
2answers
451 views

Align nodes containing numbers on the decimal separators

In a plot, I have several vertically distributed nodes containing numbers with different numbers of digits before and after the decimal separator, and a trailing percent sign. I would like to align ...
27
votes
1answer
1k views

How to add a regression line to randomly generated points using pgfplots in Tikz?

\documentclass{article} \usepackage{tikz} \usepackage{color} \usepackage[active,pdftex,tightpage]{preview} \usepackage{pgfplots} \usepackage{pgfplotstable} \begin{document} \begin{tikzpicture} ...
25
votes
4answers
1k views

A rather difficult ring like picture to be drawn

I desire a figure similar to the following: \documentclass[tikz,margin=10pt]{standalone} \usepackage{mathtools,amssymb} \begin{document} \begin{tikzpicture}[scale=2,transform shape] \draw (1,0) ...
25
votes
3answers
6k views

How to design a 3D donut pie chart with pgf-plot?

It seems that pgfplots users don't like pie charts but sometimes we can't go without (for some reasons). So I was wondering if there was a way to make what is called a donut chart. For example one ...
25
votes
3answers
5k views

filling area between 2 functions, with shading

I would like to plot two (rather simple) functions f, g over domain -2:2 and fill the area between them. The fill color should be red if f > g and green if f < g (for example), and in later ...
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 ...
25
votes
1answer
1k views

How to make pdfLaTeX multithreaded when `--shell-escape` is enabled?

I am using \write18 enabled (or --shell-escape) with externalization to compile a bunch of PGFplots. The first run takes much time, and I noticed that pdflatex only runs on one CPU core. Is there any ...
24
votes
3answers
9k views

Aligning subplots in a pgfplots figure

I have the following figure (a very, very stripped down version of a figure I created using matlab2tikz) My problem is that the subplots are not aligned correctly due to the fact that the y axis ...
24
votes
1answer
6k views

How to prevent pgfplots from using the 10^n notation for axis ticks

When creating a plot like this one \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot coordinates { ...
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 ...
24
votes
1answer
6k views

TikZ: How to get a few smooth grid lines for surface plots

I want to produce smooth surface plots with smooth grid lines using TikZ/pgfplots. Usually, this can be achieved using e.g. [samples=100], but this also draws 100 grid lines. I basically want that ...
24
votes
1answer
428 views

How to get a Waddington landscape?

The idea is to make a plot like this Source: http://figshare.com/articles/_Waddington_s_8220_Epigenetic_Landscape_8221_/620879 But only with 2 wells in the front, not 4. Also the colors don't ...
23
votes
3answers
3k views

How can I make plots with TikZ which look like the new Mathematica 9 plots

The new Mathematica 9 is out! I would love to know how to make similar plots to the one's advertized, particularly the following: and Here is a simple plot to get started. %& -shell-escape ...
23
votes
4answers
3k views

Differential Equation direction plot with pgfplots

In earlier thread Jake provided some code whom successfully draws the following differential equations in the range [0; 1] dy/dx=2*x dy/dx=x*sqrt(x) See: How to draw slope fields with all the ...
23
votes
5answers
2k views

Lower and upper Riemann sums

I am trying to create a few images for educational purposes. Therefore I need to be able to illustrate the area under various functions, using lower and upper riemann sums (rectangles) Reason for not ...
22
votes
2answers
5k views

Fill the area determined by two pgfplots graphs

I need to fill the region determined by two (Gaussian) curves and the right red line (the region is brushed in green in the figure below). I also wonder what is the best way to draw vertical line ...
22
votes
2answers
4k views

Fill between two curves in pgfplots.

How to accomplish fill between two curves in pgfplots? For example, I have ... \addplot coordinates {(0,1) (1,1)}; \addplot file {something.dat}; ... and I would like to have filling between those ...
22
votes
2answers
4k views

how to keep a 1:1 scale with x and y axis

I have been searching for hours now on how to fix these small problems, and I am finally admitting defeat and humbly ask for help. Lately I have been going over some of my badly drawn figures, trying ...
22
votes
2answers
7k views

How to combine fill and pattern in a pgfplot bar plot?

Is it possible to combine a TikZ pattern with a background of a chosen color? \addplot[black,fill=yellow,pattern=north east lines] ... yields bars which have black stripes on white (transparent?) ...
22
votes
1answer
2k views

Pre-defined color cycles à la RColorBrewer?

When I have multiple line plots in pgfplots, the colors of the lines cycle through a few colors (my guess is the colors are blue, red, black and dark khaki) before repeating with different marks. See ...
22
votes
1answer
580 views

Does pgfplots support “spatial” plotting?

As the title states, I like to know if I can plot "spatial" with pgfplots. And I think I have to explain what I mean by that (I couldn't find a good expression in english): In a pgfplots 3d plot, ...
21
votes
1answer
5k 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 ...
21
votes
3answers
1k views

Draft mode for pgfplots

I'm working on a fairly big document that has a lot of graphs of functions- so far it has around 200, by the end it will have around 1500. I use pgfplots for each graphic, and the functions are pretty ...
21
votes
1answer
9k views

How do you remove the axis multiplier?

A chart with data in the range of 200,000 and small difference between max and min values, will be assigned a 10^5 multiplier to the entire axis. This results in the ticks becoming meaningless, since ...
21
votes
1answer
5k views

How can I make my pgfplots ylabel multiline?

My pgfplots ylabel text is too long and looks strange. Can I make it multiline?
20
votes
5answers
7k views

Can I use pgfplots to make a boxplot

My current plotting tool for my papers is pgfplots for nice consistent plots. Now I would like to add a boxplot. Is this possible with help of pgfplots, or any helper package?
20
votes
3answers
1k views

Isometric Elevation Grid in TikZ

Is there a (simplistic?) way to draw a 3D elevation grid like this in Tikz or PGFPlots? The blue line should be able to move up or down and, eventually, submerge the interior blocks. I've looked ...
20
votes
1answer
6k views

What does “running in backwards compatibility mode” mean and what should I fix to get rid of it?

I was typesetting a Tex file, but I got this warning: ! Package pgfplots Warning: running in backwards compatibility mode (unsuitable tick labels; missing features). Consider writing ...