{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

12
votes
1answer
2k 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 ...
12
votes
1answer
4k views

Trend line or line of best fit in pgfplots

Is there an "out of the box" way to automatically draw the trend line in pgfplots? Below follows a basic illustration of a scatter graph with a line of best fit:
12
votes
1answer
951 views

Draw a line between data points in two different pgfplots (subfigures)

I have two different pgfplots in two subfigures. I want to draw a line between the red circled data points and the blue ones. I added lines manually with LibreOffice Draw to show you what I mean. My ...
12
votes
1answer
1k views

locally disable automatic ylabel rotation

Ordinate axis labels are rotated by default. This is not useful in case of short, single letter labels such as $\phi$. How can I suppress rotation easily in a given plot? I couldn't find anything ...
12
votes
1answer
1k views

Plot x y data from different files/tables

I have two data files (xxxx.txt and yyyy.txt), each only containing one column of x and y data respectively. Now I want to plot these two data together in a simple 2D diagram. Has anybody an idea how ...
12
votes
1answer
4k 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 ...
12
votes
1answer
14k 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}. ...
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, ...
12
votes
1answer
193 views

Fractions in annotations

I want to use the \frac command in an annotation to a line \documentclass{standalone} \usepackage{pgfplots} \usepackage{amsmath} \begin{document} \begin{tikzpicture} \begin{axis} ...
12
votes
1answer
796 views

pgfplots: colorbar: align y ticklables to the right

I have a colorbar in pgfplots and would like to have the y tick labels aligned to the right. Using colorbar style={yticklabel style={align=right}} did not work for me. The left colorbar shows the ...
12
votes
1answer
721 views

Brownian motion with drift

I have a code for the Brownian motion and it indicates three paths which initially started at point 0. My goal is to increase the initial starting point from 0.0 to e.g. 0.6. This is achieved by ...
12
votes
2answers
505 views

How can I do an affine coordinate transformation in pgfplots?

It is possible to perform a general affine coordinate transformation in TikZ by combining the shift, x, and y keys (or just the generalized cm key to set the coordinate matrix and shift). This allows ...
12
votes
1answer
719 views

Building a 2D histogram with PGFPlots

What I want to achieve The framework ROOT can create 2D histogram plots with colored boxes indicating count rate that looks something like: My question is really only: can I produce this kind of ...
12
votes
1answer
403 views

Drawing a semicircle in 3D with pgfplots

I'm trying to make a plot of a torus with a semicircle drawn on its surface. The following MWE \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} ...
12
votes
2answers
518 views

pgfplots: get color setting from table

I want to plot multiple lines using pgfplots. Each of the lines should have a color, depending on the group it belongs to. In the example attached, a table is provided, containing all the ...
12
votes
1answer
669 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 ...
12
votes
1answer
3k views

How can legend entries be obtained from different plots in a groupplot?

I would like to place a legend outside an axis using symbols from multiple plots within a groupplot. Trying it the way I show below doesn't seem to work, just the last entry is shown. How can this ...
12
votes
1answer
333 views

Having tick labels like 1, 10, 10^2, 10^3,

I would like to have y tick labels like 1, 10, 10^2, 10^3, ... So far I found found to display them either 1, 10, 100, 1000, ... or with exponents. Is this possible with pgfplots?
12
votes
1answer
258 views

Climographs (climate diagrams) with pgfplots

I'd like to create climographs (climate diagrams) with pgfplots, but these graphs have some special rules (defined by Walter and Lieth about 50 years ago) for axis scaling which I have absolutely no ...
12
votes
1answer
470 views

pgfplots: Coloring a Single Column in a Histogram Differently

I have a huge data file and want to visualize the data using histograms. I would like to color a single columns differently than the rest. Here's an example from the documentation (Section 5.11.2 ...
11
votes
3answers
4k views

Label a single coordinate (pgfplots)

I have the following plot: \begin{tikzpicture} \begin{axis}[grmin=-5:5 -5:5] \addplot[mark=none] {x^2/4}; \addplot[mark=none] {-1}; \addplot[mark=*] coordinates {(0,1)}; ...
11
votes
2answers
6k views

Histogram with Tikz

I am a newbie in TeX. And I need to use Tikz to make a copy of this histogram Of course, I am able to make something similar. Unfortunately, I need a replica (90%) of it. Can anybody help me? ...
11
votes
3answers
464 views

PGFPlots: How to draw a label at a zero of a function?

Is there an easy method to construct a node (and hence a label) at a zero of a function, i.e. at the intersection of the function with the x-axis? The examples I found were somehow too complicated, ...
11
votes
2answers
1k views

pgfplots quadrics

I wonder whether it is possible to draw the three following quadric surfaces (cone, hyperboloids) x^2+y^2-z^2=0 x^2+y^2-z^2=1 x^2+y^2-z^2=-1 (and the axis) using pgfplots 3d or TikZ as it is ...
11
votes
4answers
814 views

Plot the cusp catastrophe surface

I'm trying to draw (plot) the Cusp catastrophe surface into latex using any software logic. I am completely stuck because I'm definitely not a mathematician. The surface has the potential: V(x) = ...
11
votes
4answers
2k views

Plot inverse function in pgfplots

pgfplots is not quite comfortable plotting sqrt(x) near x=0. The graphic can be improved by setting samples=2000 (not less), but this seems overkill to me. Is there a way to plot x as a function of ...
11
votes
2answers
1k views

plot 3d graphs of functions defined implicitly

How can I plot 3d graphs of functions defined implicitly (quadratic forms, for Linear Algebra course notes -- I'd like to include lots of examples)? As far as I can see it is not possible with ...
11
votes
2answers
2k views

pgfplots: mark max/min value of a function

How can I mark the maximum or minimum value of a function like x^2 in pgfplots? \begin{tikzpicture} \begin{axis} \addplot+[mark=none] plot {x^2}; \end{axis} \end{tikzpicture}
11
votes
2answers
2k views

How to plot three-dimensional polar functions with pgfplots

I would like to plot the following functions with pgfplots: I know how they are defined: \sqrt{r}\sin\frac{\theta}{2}, \sqrt{r}\sin\frac{\theta}{2}\sin\theta, \sqrt{r}\cos\frac{\theta}{2}, ...
11
votes
2answers
791 views

How can I plot two lines in the same style (using cycle lists) with pgfplots?

I am using cycle lists and the \addplot+ command to plot lines in different styles. I would like to plot several things using each style, however, like this: % Plot using style 1 \addplot+ ...
11
votes
3answers
4k views

Using LaTeX to draw time series graphs and histograms

I have some graphs I drew in maple, some simple line plots and histograms. Now I'd like to redraw these graphs in LaTeX, so I can do fancy stuff in beamer like have one histogram appear, and then ...
11
votes
3answers
2k views

Disabling the arrows that appear in pgfplots on the axes

By default in PGFplots, when axes are only shown in the bottom left corner, arrows appear at the end of the ends of axes lines. How can I change the defaults so these arrows do not appear? Edit: ...
11
votes
2answers
2k views

pgfplots: Grid Lines below Filling

I want to fill the area between two curves and have the grid lines below the filling. Is this possible? (From Showing grid on top of plot fill with PGFplots? I thought axis on bottom might work, but ...
11
votes
2answers
1k views

Background color in pgfplots that extends beyond the axis of the plot

I am interested in adding a background-color to my pgfplots plot that extends beyond the axis of the plot. See the image bellow for clarification; I am interested in adding a background color such as ...
11
votes
1answer
9k 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 ...
11
votes
2answers
4k views

Positioning a tikz scope relative to another tikz scope

In the manual of PGFplots on page 333 the author describes how to position an axis environment relative to another axis environment: \begin{tikzpicture} ...
11
votes
2answers
811 views

pgfplots data time format

I have this type of data set: Time State 22:54:14.716 5 22:54:14.716 5 22:54:14.716 5 22:54:14.716 5 22:54:14.729 4 22:54:14.919 1 22:54:14.919 1 22:54:15.128 5 I ...
11
votes
1answer
6k views

pgfplot: Datafile format for datetime field

I have a datafile (which I may manipulate to any format), it contains a date-time stamp currently in the form "year-month-day hour:min" and a single variable for each recorded time. When I attempt to ...
11
votes
1answer
1k views

How to plot the first n rows of a table using pgfplots?

When using pgfplots, is there a way to plot only the first n rows of a given table ? Considering the following MWE file: \documentclass[tikz]{standalone} \usepackage{tikz} \usepackage{pgfplots} ...
11
votes
2answers
1k views

How to control pgfplots axis scaling for engineering notation (multiple of 3 exponent)?

The automatic power-of-ten scaling of pgfplots is a great feature that unclutters the numeric ticks in the axis (see image). However since the exponent value (e.g. 10^3, 10^4) is difficult to keep ...
11
votes
1answer
2k views

Add grid only on y-axis (pgfplots)

I would like to add only a grid on the y-axis. Here is my MWE: \documentclass{scrreprt} \usepackage{tikz, pgfplots} \begin{document} \begin{tikzpicture} \begin{semilogyaxis}[ /pgf/number ...
11
votes
2answers
226 views

Can I rotate a marker with a scatter source?

I'd like to be able to use pgfplots to show a skier going down a ski slope. Here is what I have done so far. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.7} \makeatletter ...
11
votes
2answers
483 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 ...
11
votes
1answer
3k views

PGFPlots: Change the color of axis lines

I want to change the color of the axis lines only without changing the color of the axis labels, tick labels etc. MWE: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} % ...
11
votes
1answer
3k views

Scaling colormaps with pgfplots

I have two surface plots, which I would like to have to same color for the same height. So, as the first plot is dark blue for f(x,y)=0, the right plot should also be dark blue for f(x,y)=0. However, ...
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 ...
11
votes
1answer
4k views

Chart with long x axis text labels looks ugly

Thanks to Caramdir and Alan Munn I am now able to create basic bar charts that use text as x axis labels. Functionally they are perfect, but some of them look kind of ugly. See for yourself: ...
11
votes
2answers
650 views

TikZ: Regression Line with Residuals

Desired Output I made this diagram in R with ggplot2. Now I want to reproduce this diagram with Tikz. My MWE is: \documentclass[tikz]{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} ...
11
votes
1answer
805 views

How to jam the axis of a pgfplots plot?

I need to have some kind of jump on the axis of the plot in pgfplots package. Something similar to the following figure where some part of the scales are jammed. It would be interesting to have ...
11
votes
1answer
2k views

how to remove pgfplots circular points

In the graph below, there are large circular point marks. Is there a way of removing them? My graph code is \begin{figure}[H] \begin{tikzpicture} \begin{axis}[ height=9cm, width=12cm, ...