Hot answers tagged

38

In order to colour each bar differently and make it appear with its own legend entry, each bar needs to be handled as its own plot, i.e. it needs its own \addplot ... command. Fortunately, you don't have to write \addplot ... seven times, but instead you can use \pgfplotsinvokeforeach {0,...,6} { \addplot ... }. I would suggest you provide the data in a ...


15

The approach for combining different y-axes when using groupplots is very similar to that when using just one plot: You draw the second set of plots on top of the first one, hiding the axis lines and axis labels, and moving the y(tick)labels to the other side: \documentclass{article} \usepackage{pgfplots,pgfplotstable} \usetikzlibrary{pgfplots.groupplots} ...


13

Short answer: Paste the following code snippet into your preamble, and then define your overall labels using groupplot ylabel=<label> (they can be styled using every groupplot y label/.style): \makeatletter \pgfplotsset{ groupplot xlabel/.initial={}, every groupplot x label/.style={ at={($({\pgfplots@group@name\space c1r\pgfplots@group@...


11

You simply need to adjust the height of the color bar plot. This can easily be accomplished by doing: every colorbar/.append style={height=<height specification>} However, often you will use different heights for different groupplots. Therefore a more general approach would be: every colorbar/.append style={height= 2*\pgfkeysvalueof{/pgfplots/...


11

Since the Lambert W function is a multivalued non-elementary function, then PGFplots can't plot it by just typing \addplot {LambertW(x)};. On the other hand, the inverse function, y e^y is elementary and can easily be plotted and as a result, a simple parametric plot will do the trick. If you want to have the -1th and 0th branch of the Lambert W function ...


10

You can redefine the every axis y label style by increasing the xshift value as required. \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{groupplots} \pgfplotsset{compat=1.6, ylabsh/.style={every axis y label/.style={at={(0,0.5)}, xshift=#1, rotate=90}}} \begin{document} \begin{tikzpicture} \begin{groupplot} [...


10

The groupplots library keeps the value of the current plot in the \pgfplots@group@current@plot count. So you can create the titles automatically using the alphalph package and the following style: \makeatletter \pgfplotsset{ auto title/.style={ title=(\AlphAlph{\pgfplots@group@current@plot}) } } \makeatother Then you just add auto title to ...


9

You could add a \coordinate in the top and bottom groupplot, and draw the line afterwards using those as a reference. \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{groupplots,units} \begin{document} \begin{tikzpicture} \begin{groupplot}[ group style = {group size=1 by 2, x descriptions at=edge bottom, vertical sep=0.2cm}, ...


8

To place the pie charts, you can use \subcaptionbox (from the subcaption package); the code for the pie inclusion can be shortened with the help of a new command \putpie; using two minipages inside a \makebox you can place the legend at the desired location: \documentclass{article} \usepackage{pgfplots, pgfplotstable} \usepackage{subcaption} \...


7

You could use two groupplots environments, where the height of the axes in the second is half that of the first. To align them properly I placed the first sub-plot of the second groupplot relative to the first groupplot, with \nextgroupplot[anchor=north west, at={($(left plots c1r1.north east) + (0.2cm,0)$)}] left plots is a label for the first groupplot,...


6

You can do it with \draw[thick,red] (group c1r1.north) -- (group c1r2.south); Code: \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{groupplots,units} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{groupplot}[ group style = {group size=1 by 2, x descriptions at=edge bottom, vertical sep=0.2cm}, ...


6

Your plots are too wide. You may try to put 2 plots in a row instead of 3. However, there is always this box techniques that can be used. \documentclass[]{article} \usepackage{pgfplots, alphalph} \usepgfplotslibrary{groupplots} \begin{document} \begin{figure} \makebox[\textwidth]{% \begin{tikzpicture}[font=\footnotesize\sffamily] \begin{...


6

You can load subcaption and caption packages and use \captionof inside a node like \node[text width=6cm,align=center,anchor=north] at ([yshift=-5mm]my plots c1r1.south) {\captionof{subfigure}{Pressure relative (P/P)\label{subplot:one}}}; The node option textwidthis needed for\captionof` to work inside the node. \documentclass[french,12pt,oneside,...


6

The Lambert W function is built into Sage, so you can access that through sagetex. Notice the principal branch uses 1 argument but the other branches needed two to make it clear which branch you want; e.g. lambert_w(-1,t2).n(digits=6) specifies the -1 branch. Sagetex requires local installation of Sage or, to avoid that, a free SagemathCloud account. \...


5

Based on the comment by @zeroth, I was able to put together a manually aligned set of plots. I'm pretty sure the code can be improved (particularly the placement of the figure caption) and I'm not at all sure what problems this might have (with, for instance, externalize), but this solves my problem. \documentclass{article} \usepackage{pgfplots} \...


5

Disclaimer: This is not a complete answer as it only deals with plot width, label font sizes etc., but not with the node size and placement. It'd be too long as a comment unfortunately. I have found that it is possible to get proper font sizes when using groupplots by compensating for the horizontal spacing between plots. Your \includegraphics command is ...


5

Box plots are always placed at the coordinate specified with boxplot/draw position. This, in turn, defaults to 1+\plotnumofactualtype, but it can be customized to other values. In your case, you can simply place all your plots into one axis and assign an individual boxplot/draw position to each. Here is an approach which defines a math expression which ...


5

If you don't mind augmenting one internal macro of the groupplots library a little bit, you can define a new sticky options style that you can use in the optional argument to \nextgroupplot[...] to set options that will stay active for the remainder of the groupplots environment (or until you call sticky options again). Putting the following code chunk into ...


5

You need not use empty \nextgroupplot to insert the Row 1 etc. But use a node like \node[rotate=90,above=5mm] at (my plots c1r1.west) {Row 1}; \node[rotate=90,above=5mm] at (my plots c1r2.west) {Row 2}; \node[above=5mm] at (my plots c1r1.north) {Column 1}; \node[above=5mm] at (my plots c2r1.north) {Column 2}; The width problem comes as you have width=1cm ...


5

Use xticklabels at=edge bottom as group style option. Code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{pgfplots.groupplots} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{groupplot}[group style={ group size= 2 by 2 ,xticklabels at=edge bottom % <- added } ,height=6cm,width=5cm,ybar,xtick=data,...


4

(I used random numbers because I was too lazy to save your four data files.) Here a suggestion that gives Your first two requirements can be achieved by changing the title style. This actually appends the options you define to the node creating the title. Adding some negative yshift moves it closer to the axis, filling it adds the background color. You ...


4

To add legend to a place to the right of the plots, one needs to add a legend style to the groupplot environment where at=() is the key. The (0,0) means the lower left of the corner while (1,1) means the upper right corner. Such system is called axis description cs documented on page 103. [legend style={at={(1.03,1.4)}, anchor=north west} Code: \...


4

To plot spectrometer output in this format, which is apparently something of a standard, you can use a coordinate transform. If you set x coord trafo/.code={ \pgfmathparse{#1-0.5*(#1-2000)*(#1>2000)} } the x unit distance above 2000 is halved. To get correct tick labels, you also need to define the inverse transform: x coord inv trafo/.code={ ...


4

You can pass the option /tikz/background rectangle/.style={draw=none} to groupplot (the prefix is required since those are TikZ keys): \documentclass{standalone} \usepackage{pgfplots} \usetikzlibrary{backgrounds,pgfplots.groupplots} \tikzset{ every picture/.style={ framed, background rectangle/.style={ draw=black!80, rounded corners=.5ex } ...


4

This is a bug in pgfplots 1.11. I downgraded to pgfplots 1.10 and everything looks as expected.


4

You are plotting the marks too and since those marks are too close to each other, the line looks thick. For this either remove + from \addplot or pass the option no marks to \addplot. Then the effect of changing colour can be seen. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \usepgfplotslibrary{groupplots} \begin{document} \...


4

You don't need to use set layers to get what you want. Just axis on top is sufficient and axis on top itself sets layers. I have made the grid black just for illustration. If you insist on using set layers put it after \begin{tikzpicture} like \begin{tikzpicture} \pgfplotsset{set layers} But for this particular case, it is not doing much. You have ...


4

The "slice" you see at the top of the two contour plots are actually colorbars for the two uppermost plots. These are included as you have added colorbar horizontal to the whole group. Each axis environment inherits these options, meaning every plot in this group will have its own colorbar. To see this clearly you can increase the vertical spacing between ...


4

Inside a groupplot, each plot is named group c<number>r<number>, where the last part indicates the column and row number, respectively, for the plot. Using this, you can use the calc library to place the last plot, using for example \nextgroupplot[title=\textbf{(c)}, at = { ($ ( $ (group c1r2.south west) + (0,-100pt)$ )!0.5!(group c2r2.south ...


4

The problem appears to be an expansion issue in the interaction of pgfplots and \includegraphics. It can be reduced to the following minimal working example: \documentclass{standalone} \usepackage{graphics} \newenvironment{type}[1]{% \newcommand\getFile[1]{% directory1/#1/##1} }{} \begin{document} \begin{type}{directory2} File: \def\...



Only top voted, non community-wiki answers of a minimum length are eligible