{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

53
votes
6answers
2k 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, ...
27
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. ...
20
votes
2answers
3k 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 ...
27
votes
5answers
2k 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
2answers
1k 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 ...
19
votes
3answers
3k views

TikZ externalize, pgfplots and animate

I gave a very fetching presentation written with beamer today. It included a pgfplot animated with the animate package, and the result was fantastic. The problem? One of my colleagues wants to borrow ...
18
votes
2answers
2k views

Making overlay figures in TikZ

I'm trying to reproduce the following two figures in TikZ. My attempted code for Fig 1 is \documentclass{minimal} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw ...
17
votes
1answer
2k views

How can I draw a chart in the economist style with pgfplots?

I am trying to draw a chart with "The Economist" style. With tikz, I draw this chart clumsily, so I would like to know is that possible to draw this chart elegantly with pgfplots. ...
17
votes
3answers
6k 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 ...
14
votes
1answer
1k views

Tikz: intersection of line and plane

I am struggling with drawing a plane and a intersecting line. I would like to have the line C,P',P in the image, disappear if it is "behind" the plane and have it reappear if it is not behind the ...
14
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 ...
13
votes
1answer
2k views

geographic maps with TikZ/pgfplots

I have recently discovered pgfplots and I love it. I'm converting the figures from my thesis to pgfplots, or at least the ones I have made myself. One of my figures is a map that I created using the ...
8
votes
1answer
3k views

How to plot intervals and points in the real line?

I need to plot a series of sets of intervals (and points) in the real line. Intervals can be closed, left/right-open or open. (Open/closed ends are marked with empty/filled circles) and isolated ...
7
votes
3answers
2k views

How to coherently combine 3D and contour plots with pgfplots

Both contour and 3d plots can be done easily in pgfplots, but I have a hard time combining them nicely. Here's an example of what I'd like to achieve (from the matplotlib examples):
16
votes
1answer
1k views

Plotting Normal distribution in pgfplots

I'm trying to reproduce the following diagram in TikZ and pgfplots. My MWE with regenerated graph is below: \documentclass{standalone} \usepackage{pgfplots} \begin{document} ...
13
votes
2answers
2k views

How to select a finite number of samples from the file when plotting using pgfplot

I have a datafile containing thousands of points of which I need to plot only the first 100 points. How to do this using pgfplots? I tried the following with no effect. \begin{axis}[
xlabel=k,
...
9
votes
1answer
3k views

pgfplot with constant decimal places on ticks

I'm trying to display the tick labels of the y axis of just this graph within my document formatting to two decimal places. I've tried the following code but it seems that it doesn't like the way I'm ...
13
votes
1answer
8k views

pgfplots: Legends in multiple y-axis plot overlapping

I am trying to add a legend for two plots on two different y-axes, however they are overlapping each other and each one is being written in its own box. I would like for both of them to share a single ...
10
votes
2answers
1k views

Intersection of 2 surface plots in pgfplots

My question is pretty much a duplicate of this one. I'd like pgfplots to display the intersection between tho surface plots properly. Unfortunately, my function is quite different from the one in the ...
16
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?
13
votes
1answer
2k views

How to use a string column with pgfplotstable to label datapoints in a pgfplot?

I have a comma-separated list of data points. They should be plotted as a scatter plot, and should be labeled using data from the .csv file. Having specified the first column of my file as string ...
12
votes
1answer
748 views

How can I automatically mark local extrema with pgfplots and scatter?

I am trying to have TikZ automatically mark a local maximum in a fourth-degree polynomial I built using a curve-fitting tool. I am new to LaTeX and TikZ, and am a bit overwhelmed - there seem to be a ...
12
votes
1answer
1k views

3D Arrow Tips for TikZ/pgfplots

I really like the arrow tips shown in How to get rid of the viewer's (incorrect) axes in an Asymptote 3D graphics and am wondering how to produce this in pgfplots: I admit I have not tried ...
12
votes
1answer
2k views

Stacked barplots/groupplots with text labels in x-coordinate

I was trying to stack a groupplot, or was it grouping a stacked plot? However I was trying to get something like: The ybar stacked option works quite nice here. But when I try to adapt it to a ...
12
votes
1answer
11k 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}. ...
9
votes
1answer
193 views

Local colormaps in global coordinate system

I am trying to get a surface graph with two colormaps. Instead of using the full Z range i want to give the first surface its own colormap and the second surface should receive its own colormap too ...
9
votes
1answer
1k views

Having y-axis in log scale base 2 using pgfplots

I have made a chart using pgfplots as written below and I want to have the y-axis in logarithmic scale. This code works fine but the base of the logarithm is 10. How can I change it to base 2? ...
9
votes
1answer
1k views

How to Graph Floor/Ceiling Functions in LaTeX (PGFPlots)

I am trying to make a graph of some floor/ceiling functions for examplep the floor of 3x+2 like this: http://www.wolframalpha.com/input/?i=graph+of+floor%283x%2B2%29#=. However, I searched through ...
8
votes
1answer
860 views

Pgfplots: title covers scientific notation

I have a problem with pgfplots. As you can see by compiling my MWE, the title of the plot covers the scientific notation of the y axis. Is there any way to fix that (move the title or the scientific ...
8
votes
1answer
873 views

pgfplots: color a surf using arbitrary colors

I am trying to figure out if there is an equivalent in pgfplots to what in MATLAB is done through the following command: surf(A,B). This would plot the geometry A, using the colors specified in B. I ...
7
votes
1answer
413 views

Align pinned nodes in PGFplots

I'm working with plots generated from matlab2tikz and I have several plot lines close to each other. Labeling them is proving difficult, but I believe a good looking solution could be to list the ...
7
votes
2answers
1k views

pgfplots: how make axes go through origin?

For pgfplots, in all the 2D examples I've seen, and in the manual, the location of axes seems to be specified in terms of location within the plot box, i.e.,relative to top, bottom. How does one ...
7
votes
1answer
661 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 ...
6
votes
1answer
523 views

2d graphs in a 3d plot

I am trying to create 3d plots with several 2d graphs, like in Plotting several 2d functions in a 3d graph. However the end result looks like this: Using \closedcycle doesn't help either, as it ...
6
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, ...
5
votes
1answer
5k views

Different marker shape for pgf/TikZ

I have a figure in my paper which compared 6 different cases. The figure needs to be in black and white. In below is the code I used to create the figure. \documentclass{standalone} ...
4
votes
1answer
125 views

PGFplots and table with different number of elements in columns

I am trying to plot a table where I have different number of elements in the columns. In the MWE, the pairs (x1,y1),...,(x4,y4) all have different number of elements, can I use PGFplots in such ...
14
votes
1answer
2k views

Add a legend title to the legend box with pgfplots?

I am using the awesome pgfplots package to draw some plots. I usually use \addlegendentry and get a nice default legend box. There are some options for legend box placement and layout (e.g. number of ...
13
votes
2answers
983 views

Allow underscore in PGFPlots tick labels read from table

I'm trying to use the text data from a table column as the tick labels in a plot. The text data contains underscores, which makes LaTeX throw a Missing $ inserted error. I'd usually get around this by ...
13
votes
2answers
4k views

ylabel postion with pgfplots

I am using pgfplots to plot some data, but I am having problem you see in the image below. Basically, the ylabel overlaps with the axis numbering. I have googled a LOT but couldn't find any solution. ...
12
votes
1answer
903 views

How to scale existing coordinates data in pgfplots?

I have a plot with its data, for example \documentclass[]{article} \usepackage[]{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[] \addplot+[%multiply x data by a factor here, multiply y ...
11
votes
2answers
435 views

Visualize data on a variable-radius graph/network

I am trying to visualize the output from a simulation model I have been working with. The simulation finds the steady-state solution to a system of differential equations on a variable-radius (and ...
10
votes
1answer
454 views

Is there a workaround against loss of precision in pgfplots axis?

I am generating a bunch of plots automatically using pgfplots. For some datasets the span of data in one axis (y) is relatively small (relative to the absolute value) and therefore pgfplots when ...
10
votes
1answer
2k views

What “smooth” plot interpolation algorithm does pgfplots use?

In the pgfplots manual it says: \addplot+[smooth] Smooth plots interpolate smoothly between successive points. In order to choose the right sampling of points from a function evaluation for ...
8
votes
1answer
553 views

How to reuse the plotmark styles from PGFPlots outside the tikzpicture environment?

In a figure caption or in the main text I want to reuse the style of the plotmarks or the combination of line and symbol as in the figure legend. As I did not find a command to reuse the legend image ...
7
votes
1answer
418 views

Read boxplot prepared values from a table

Update: Is there any possibility of drawing two box plots this way using a single datatable as in the updated MWE below? I'm trying to use pgfplots 1.8's shiny new boxplot feature. As I am also ...
7
votes
2answers
661 views

Particular bar plot with pgfplots: bar color = category

I want to create a bar plot using pgfplots. In this plot the bars should be represent categorys. So that one color suggest the category. The categorys are: 0-8 None 9-13 Minimal 14-19 Slightly ...
7
votes
3answers
2k views

pgfplots with symbolic x coords and error bars

I am trying to plot explicit error bars like this: \begin{tikzpicture} \begin{axis} [symbolic x coords={Lighting,Computers,Total}] \addplot+[only marks] plot[error bars/.cd, y dir=both, y explicit] ...
7
votes
1answer
757 views

Calculate and draw difference of two plots automatically

I'm trying to automatically generate a plot, which visualizes the difference of two other plots. The input source is a single(!) file. The data is filtered by one column with /tr/rowfilter. Here is an ...
6
votes
1answer
856 views

pgfplots: color a (3D) surf using arbitrary RGB colors

I would like to color a surf using arbitrary RGB colors (unlike this question, which just colors the surf using the colormap). In this minimal example (which plots the x+y function), I would like the ...