Articles of pgfplots

pgfplotsset{compat=1.9} causes y=0 error bar to disappear

I am producing a stacked bar chart or two series with error bars that describe the uncertainty in their sum. I apply the error bars as properties of the second plot. If I use \pgfplotset{compat=1.9}, then points where the second plot value is zero (no rectangle) don’t get error bars, even through the error amount […]

Pattern in \addplot inherits dashed option from previous \draw

I want to fill the area between two curves with a pattern, let’s say horizontal line. Since I want some other dashed lines below these curves, I use \draw[dashed] and then \addplot[pattern=horizontal lines] (twice). I notice that the area is filled with two different pattern options, dashed and solid and the cause is the previous […]

Create custom colored PGFPlots ybar with consistent spacing

I am trying to create a ybar graph that has consistent spacing between a set of columns. I have obtained the color scheme I need in the following example, based off guidance from this question on here \documentclass{memoir} \usepackage[left=1.5in, right=1in, top=1in, bottom=1in, headsep=0.1in, head=0.4in, includehead, includefoot, marginparsep=0in, marginparwidth=0in,footskip=0.4in]{geometry} \usepackage{graphicx} \usepackage{pgfplots} \usepackage{xcolor} \pagecolor{black} \pgfplotsset{width=7cm,compat=1.5.1} \usepackage{siunitx} \sisetup{inter-unit-product={}\cdot{},sticky-per=true,multi-part-units=single,separate-uncertainty=true,list-units=single,range-units=single,detect-all,detect-weight=true,detect-inline-weight=math} […]

Automatically choosing preset color schemes in pgfplots based on number of entries

This is really more of a question to satisfy personal curiosity than to solve a real problem. When choosing the colour schemes for my plots, I try to select colours that will work well with the amount of items involved in the plot. This means using sets of colours that are above all aesthetically pleasing, […]

dashed line in pgfplots legend results in incomplete marks

When defining the pgfplots legend entries myself, I have a problem when using dashed lines in combination with marks. The mark is also dashed (or dotted, etc.), just as the accompanying line is. Is there a way of making sure that marks are drawn completely when using dashed/dotted/etc. lines? MWE: \documentclass{report} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ […]

legend looks strange for joint line and bar plot in pgfplots

I am trying to draw both a line plot and a bar plot in the same plot. However, the legend for the line plot looks wrong. Question: How do I make the legend look like the legend for a regular line plot? \documentclass[margin=2mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ ybar, ylabel=Inventory, xmin=0, xmax=47, height=4cm, width=\textwidth, ymin=0, […]

tikzscale and histograms in pgfplots

Tikzscale is giving wrong results for histograms drawn in pgfplots. Histogram without scaling by tikzscale: Histogram after scaling: I have included a histogram from page 67 from pgfplots manual for version 1.7 in the MWE. The pgfplots.randn.dat file comes with the standard texlive-2012 distribution or can be downloaded from the given link. MWE \documentclass{report} \usepackage{filecontents,tikz} […]

Global legend for multiple figures

Similar to this question, I need output as follows but in a neat way. My solution code is not neat any more: I added a dummy axis to use its legend. Also the legend must be at top of the page. Here its code: \documentclass{article} \usepackage{pgfplots} \newcommand{\realplot}[1]{ \begin{tikzpicture} \begin{axis} \addlegendimage{empty legend}\addlegendentry{Matrix #1} \addplot {0}; \addplot […]

Pgfplotstable ignores chars in filename

I am using the ignore chars key from the pgfplotstable to ignore some characters in a table. However, I have noticed that it also removes characters from the file name and I am wondering if this is a bug. Here is an example where the ignored char is s. The result is that the table […]

X-Bar plot with intervall (a,b) rather than (0,a)

When one makes a xbar plot using pgfplots, the bar always goes from 0 to the requested coordinate. For example (p. 78 in pgfplots manual): \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ xbar, xmin=0, width=12cm, height=3.5cm, enlarge y limits=0.5, symbolic y coords={no,yes}, ytick=data, nodes near coords, nodes near coords align={horizontal}, ] \addplot coordinates {(3,no) (7,yes)}; \end{axis} \end{tikzpicture} […]