{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

6
votes
1answer
1k views

change color of pgfplot bar plot

I want to plot two bar plots next to each other. This works without a problem. However both use the first color defined in a pre or selfdefined colorseries. I tried to modify the color manually in the ...
6
votes
1answer
769 views

2D colors above 3D surface plot

I would like to draw a 2D, colored plot of a function above its surface plot. I tried copying the surface plot and setting z filter/.code={\def\pgfmathresult{1.4}}, but then everything is the same ...
6
votes
1answer
786 views

import input pgfplots with relative paths

The package import makes it posible to \input (and \include) a .tex document which itself \input (or \includegraphics etc.) stuff using relative paths. I was hoping that this also would work with the ...
5
votes
1answer
685 views

Multiple different meta for marker color and marker size

How do I set the color of a marker with one meta column in a table AND its size with another meta column? So in this minimal working example, how can I set the marker size with 'w1' and the color ...
5
votes
1answer
344 views

pgfplots: using path names created with foreach in pgfplotsextra

This is a follow-up to naming paths inside a TikZ foreach loop I want to plot a series of plots with names generated for each plot (usingname path global) in a foreach loop and place a coordinate at ...
5
votes
1answer
1k 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} ...
4
votes
1answer
48 views

Plotting a function defined with \pgfmathdeclarefunction

I've got a few macros that perform floating point lookups and calculations for me and I'm interesting in plotting their results. They're the kind of calculation which requires if/else, so they can't ...
4
votes
1answer
51 views

\foreach not behaving in axis environment

Am hesitant to ask yet one more embarrassing question, but I can't seem to see the problem with the \foreach in the MWE. It should produce several horizontal lines but only produces the one with the ...
4
votes
1answer
324 views

How to automatically align subfloat captions to xlabel of PGFplots?

Subfloat captions are not usually aligned with their corresponding xlable in PGFplots. One way is to manually move the captions horizontally to align them. For example, (copied from here) ...
4
votes
2answers
1k views

How can I change format of number's axis on pgfplots

I want to change format of x or y number in green box of below graph .
4
votes
1answer
2k views

Plot and label data from file with PGFPlots

Given some data from a file, I would like to use the first two columns as coordinates, and the second two columns as label for every point. The data is given in this form: x y ...
4
votes
2answers
2k views

Bar plot labels and grids

\documentclass[a4paper,11pt]{report} \usepackage{tikz} \usepackage{verbatim} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ title = {Optimalization based upon co-occurences}, ...
4
votes
1answer
316 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 ...
4
votes
2answers
1k views

Incorrect plot using Pgfplots

I'm trying to plot a function with pgfplots for LaTeX. Unfortunately, pgfplots plots the function incorrectly. Here is the LaTeX code I use: \begin{figure}[H] \centering \begin{tikzpicture} ...
3
votes
1answer
719 views

edit x-y data from different files/tables

I've two one column data files (A.txt and B.txt). To plot them together first I load dataA with \pgfplotstableset{ create on use/dataA/.style={create col/copy column from table={A.txt}{0}} } Then I ...
3
votes
1answer
702 views

multiline coords

I'm using \symbolic y coords in a xbar-plot. some of these coords are (like "jährlicher Primärenergieverbrauch") very long. so my questions are: how do I generate line breaks in coords? is there a ...
2
votes
2answers
341 views

Problem in adjusting contour label color and numbr of samples in pgfplot

I am trying to create a contour plot using TikZ. I have two questions: How can I change the contour labels color to all black? Is it normal that gnuplot responds slow for creating smoother contour ...
2
votes
1answer
200 views

Labels in xtick with pgfplots

I am using Pgfplots to make a very simple graph. I already have the code below \documentclass{article} \usepackage{tikz,pgfplots} \pagestyle{empty} \begin{document} \begin{tikzpicture}[>=latex] ...
2
votes
1answer
444 views

pgfplot barchart moving x-axis up

For the MWE below: \documentclass{report} \usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage[T1]{fontenc} \usepackage{tikz,pgf} \usepackage{pgfplots} \usepackage{slashbox} ...
2
votes
1answer
582 views

Legend with Markers for Mesh Plot

I use a mesh plot with scatter points (2d) where the colors are determined from a third coordinate of the data as described in this question. The legend however should contain the markers of a curve ...
22
votes
3answers
758 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
4answers
2k 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 ...
28
votes
1answer
654 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 ...
18
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 ...
26
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: ...
10
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 ...
15
votes
1answer
507 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 ...
15
votes
1answer
1k views

Waterfall Chart

For displaying the total effect of a series of values, a waterfall chart can be useful. For example this chart, taken from The Economist, illustrates estimated efficiency potentials in the UK public ...
13
votes
1answer
842 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
1answer
730 views

How to plot circular polarized electromagnetic wave

I am searching for a solution to get nice looking circular polarized waves in my latex document. My goal is to get a graph that looks like this: I do not want the graph to be animated but I can not ...
22
votes
1answer
4k 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 ...
14
votes
2answers
302 views

quiver plot on hyperboloid surface

Using pgfplots, I'm trying to create a quiver plot on a hyperboloid surface something like this. I was able to generate the hyperboloid surface using parametric equations. I could'nt find out how ...
9
votes
1answer
498 views

Drawing a ring around a torus (doughnut) using TikZ

I was trying to draw a 2-torus (a doughnut) using TikZ, based on the answer to my previous question Moebius Strip using Tikz, and got the following The result is impressive! However, the vertical ...
8
votes
2answers
3k views

How to stack and align multiple plots with same x but different y axes?

I have several series of datapoints from each of several sites. I would like to produce a series of stacked plots, close together as in the attached example, to allow comparison both within and ...
6
votes
1answer
1k views

How to create a gaussian curve with pgfplot?

What I want: This is what I have so far in terms of code: \newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))} % Gauss function, parameters mu and sigma \begin{tikzpicture} ...
5
votes
1answer
554 views

How to draw slope fields with all the possible solution curves in latex

Sorry, I have no code to submit, mostly because I have no idea how to do this. I want to type up my homework (I can do the homework by hand) and I am looking for a simple method that I can use ...
5
votes
2answers
540 views

How can I plot bigger amounts of data?

I am currently playing around with hailstone sequences (collatz numbers). I would like to create a plot like this (from Wikipedia): But I don't know how this kind of plot is called (it's neither a ...
5
votes
1answer
688 views

Manually add legend symbols in text (without \label and \ref)

I would like to add legend symbols from pgfplots in my text. I am aware of the possibility to use the \label and \ref commands but my setup is complicated and I fear that making it work will more time ...
18
votes
1answer
227 views

Elements that looks different when printed with colours or in BW

Is there the possibility with LaTeX of having some element that change if it is printed with colours or in black and white? I was thinking about the rectangles around links with hyperref that are ...
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} ...
12
votes
1answer
6k 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 ...
11
votes
1answer
3k views

Default color pgfplot

I noticed that when using pgfplots to make plots without specifying style, it automatically assigns the same color and line style to the first input and fifth input, which means the two curves would ...
10
votes
1answer
883 views

pgfplots: auto-size chart?

I have an xbar graph with some some data that I don't necessarily know the length of beforehand. Is there some way I can tell pgfplots to automatically expand the height of the chart according to the ...
9
votes
2answers
483 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 ...
9
votes
1answer
3k views

Grouped bar chart

I'm trying to construct a grouped bar chart and have three questions I can't seem to find the answer to: 1) How do I modify the spacings between the groups? Or at least make sure that no bars are ...
9
votes
1answer
440 views

pgfplots - Provide a detailed plot inside the main plot

I have a main plot and inside it I would like to add a smaller plot that offers a higher level of detail. A rough illustration of the above is: Notice that the smaller plot provides a more ...
9
votes
2answers
3k views

matlab2tikz - TeX out of memory

I am using matlab2tikz to import figures from MATLAB to tex. However I quickly get the message TeX capacity exceeded, sorry [main memory size = 3000000]. I have tried expand main memory using ...
9
votes
1answer
7k views

Problem plotting histogram using pgfplots package

The following code plots a histogram using pgfplots. \documentclass[a4paper]{article} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \centering ...
8
votes
1answer
526 views

Circular drop shadow around a spy in pgfplots

The pgf manual isn't really explicit about it, so i'm here to ask it to the stack communauty. I tried to put some shadow/blur effect around the spyonnode but with no effect at all ! I tried this : ...
7
votes
3answers
2k views

Easiest way to plot matrix image

Is there an easier way to create this in pgfplots than plotting the matrix image externally and using addplot graphics (as on p.42 of the pgfplots manual)? A mesh plot (as suggested for plotting ...