{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

18
votes
1answer
6k 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 ...
32
votes
2answers
3k 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} ...
31
votes
2answers
3k 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 ...
11
votes
2answers
3k views

Using a pgfplots-style legend in a plain-old tikzpicture

I am using a plain-old tikzpicture to produce a pie-chart-like plot. Now, all other plots in my paper are handled using pgfplots (which doesn't do pie charts) and have their legend typeset by ...
26
votes
2answers
4k 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 ...
12
votes
1answer
1k 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 ...
51
votes
5answers
17k 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 ...
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 ...
35
votes
3answers
10k 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 ...
35
votes
3answers
8k 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... ...
8
votes
1answer
941 views

Using pgfplots, how do I arrange my data matrix for a surface plot so that each cell in the matrix is plotted as a square?

I have a matrix of size MxN and I want to make a surface plot directly from above so that each cell in the matrix is drawn as a square. None of the pgfplots shaders really do what I want, since they ...
44
votes
4answers
5k 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?
9
votes
1answer
1k views

Is it possible to change the color of a single bar when the bar plot is based on symbolic values?

I am beginner in LaTeX, trying to use it for industrial documents. I wonder if there is a way to change the color of only one bar of the plot below, ie "TestDetails", to illustrate it is a local macro ...
228
votes
2answers
25k 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 ...
25
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 ...
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 ...
15
votes
1answer
2k views

pgfplots: externalization and legend referencing

There are some issues when using the pgfplots option legend to name together with externalization. When I disable externalization, everything works fine. When I enable externalization, I get an error ...
35
votes
1answer
8k 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.
35
votes
2answers
8k 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 ...
29
votes
2answers
3k 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.
20
votes
1answer
3k views

pgfplots: Placing node on a specific x-position

I'm trying to put some arrows on the left and right side of the maximum of a curve. The arrows should point along the curve. My problem is that if I use the [pos=X] notation I don't know where I am in ...
19
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 ...
10
votes
1answer
6k views

Legend in tikzpicture

I am looking for a way to create a legend in a regular tikzpicture. I found this Using a pgfplots-style legend in a plain-old tikzpicture but I don't know how to put the legend at the wanted ...
20
votes
2answers
3k 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 ...
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 ...
12
votes
1answer
3k views

Non-linear curve fitting with gnuplot

I am trying to use gnuplot with pgfplots in TexShop, following on from an example by Martin H in the comments here. I can get the data points in OK, and plot them but the fit (red line) does not seem ...
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 ...
10
votes
1answer
2k views

Axis with trigonometric labels in PGFPlots

How do I make the axis labels use multiples of \pi in PGFPlots?
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 ...
7
votes
1answer
429 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 ...
36
votes
3answers
1k 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 ...
16
votes
2answers
1k views

How to minimize the ink-to-data ratio for pgfplots

Tufte advocates to "minimize the ink-to-data ratio" for charts. I am trying to style a multi data series bar chart, that can have a grid and axes as shown below (chart at the left is from the ...
15
votes
3answers
4k views

Image with axis

I need to plot some data in a file (10000 records of 2 points each one) but PGFPlots is very very slow rendering it. So I'm trying to use MatLab to plot the data, capture the image without axis and in ...
11
votes
1answer
841 views

Creating Bezier surfaces using procedural graphics

Are there any package for LaTeX that can create Bezier surfaces? I mean a actual existing function that takes matrices as arguments and generates the surface, not a function written by myself.
6
votes
1answer
3k views

PGFplot to occupy full \linewidth, and aligned y=axis across tikzpicture

How do I get the tikzpicture to occupy the full \linewidth, and also have the left and right axis aligned? I suspect that some \phantom spacing applied to the tick labels will do the trick, but don't ...
6
votes
1answer
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 ...
11
votes
2answers
2k views

Coordinates of intersections

In axis environment I have a curve and a line intersecting it. How can I get components of intersection-1, intersection-2 etc. in axis units? \documentclass{minimal} \usepackage{pgfplots} ...
7
votes
1answer
2k views

Center nodes near coords in a stacked ybar plot

I'm trying to center the node values, at the middle of each bar, in a stacked plot. However I can only put those nodes in the top of each bar. Is it possible to move those down? To the center of each ...
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 ...
36
votes
3answers
2k 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, ...
22
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 ...
19
votes
5answers
6k 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?
15
votes
3answers
3k views

How to plot a surface from a set of data?

Disclaimer: I already read questions like 2D surface on a 3D surface plot external data in a file and 3D surface plots in TikZ but these did not solve my problem. I have this set of data: x y ...
12
votes
1answer
2k views

plot within a plot: zoom into a plot so that the magnified part is framed by axis with ticks and tick labels

I want to zoom into a plot much like it is possible by using the spy library but I want the spy-in node to contain its own ticks and tick labels with a finer grid than the original plot. To clarify ...
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, ...
14
votes
2answers
1k views

Use first row of a table as legend entry in pgfplot graph?

I'm using pgfplots extensively and I'd like to avoid having to write legends every time, since all the text files I want to plot have explicit headers. As a comparison, \pgfplotstabletypeset makes a ...
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 ...
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 ...
9
votes
1answer
1k views

How can I mix an “ybar” and an “ybar stacked” with pgfplots?

I tried a while to create that kind of chart with ybar but it's a mix between "ybar stacked" and "ybar". How can I do that? I tried this way but with no great results: \begin{tikzpicture} ...
12
votes
2answers
4k views

Drawing curves and multiple y-axes in one plot with pgfplots

I'm aware of the possibility given by pgfplots to have two y-axes, one on the left and one on the right with two different scales. But I'd like to explore other ways to have multiple axes, e.g. ...