Tag Info

Hot answers tagged

32

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 ...


11

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} ...


10

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 ...


9

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= ...


9

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 ...


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 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} ...


7

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}, ...


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}, ...


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

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={ ...


5

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 ...


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

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 ...


4

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 ...


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

(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 ...


3

Thanks to Jake's suggestion, a significant compression of my original solution is possible (since I don't know a thing about tikz). Also, a new version of stackengine should hit the streets this weekend. The syntax I used here will work in both old and new versions. You can control the inter-plot separation, if desired (i.e., normal hspacing will work ...


3

You can adjust the padding between the plots using the horizontal sep and vertical sep options in the group style. To adjust the style of the tick marks, use tick style=gray!50: \documentclass{article} \usepackage[demo]{graphicx} \usepackage{pgfplots} \usepgfplotslibrary{groupplots} \begin{document} \begin{tikzpicture} \pgfplotsset{% width=4cm, ...


3

Pgfplots has two parameters which control the selection of default ticks: max space between ticks try min ticks The first parameter is the primary parameter, it is used to derive the number of ticks. If this number is below try min ticks, pgfplots increases the number. Note that pgfplots only accepts specific tick locations, depending on the data range. ...


3

You don't have to use Tikz to add the labels, you can add them afterwards to the constructed box. \documentclass{standalone} \usepackage{graphicx} \usepackage{siunitx} \usepackage{tikz} \usepackage{pgfplots} \usepackage{array} \usepgfplotslibrary{groupplots} \pgfplotsset{compat=newest} \pgfplotsset{plot coordinates/math parser=false} \begin{document} ...


3

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: ...


3

In my mind, groupplots aren't really intended for this kind of thing. I suggest using two axis environments instead. Place a \coordinate in the larger axis using the rel axis cs or axis cs coordinate system, and place the smaller axis at this coordinate. In the code below you'll see \coordinate (otheraxis) at (rel axis cs:0.15,0.5); in the first axis, ...


3

Based on Torbjørn T.'s comments and expanding it with the problem of using the newest pgfplot if you installed texlive from the Ubuntu repo: To use the latest pgfplots library you need to update pgf as well (and to use tlmgr, you'll probably need xzdec as well): sudo apt-get install xzdec tlmgr init-usertree tlmgr install pgfplots tlmgr install pgf After ...


3

You can make xtick=\empty in 2nd and 3rd plots and for first and last, give them explicitly. Disable xlabels at=edge bottom, xticklabels at=edge bottom, BTW. Code: \documentclass{standalone} \usepackage{pgfplots} \usetikzlibrary{pgfplots.groupplots} \begin{document} \pgfplotsset{ compat=1.12, cycle list={ {black,thin}, }, ...


3

Another answer with better spacing between subplots: \documentclass{standalone} \usepackage{pgfplots} \usetikzlibrary{pgfplots.groupplots} \begin{document} \pgfplotsset{ cycle list={ {black,thin}, }, /pgf/text mark/style={mark=none}, } \begin{tikzpicture} \begin{groupplot}[ group style={ group name=my plots, group ...


2

You are right, the options are not reset for colorbar. I have fixed this in pgfplots. You can activate the fix in your tex files by means of \pgfplotsset{ every colorbar global/.append style={ zmin=,zmax=, } } Adding this to your preamble leads to


2

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


2

You have to set the total number of plots that will be in the groupplot environment using either group size=1 by 2 or columns=1 and rows=2. Note, that the initially value is group size=1 by 1 that means columns=1 androws=1`. So you could use \begin{groupplot}[ group style={group size=1 by 2, vertical sep=2cm}, xlabel=Order of spot, ...


2

You have clip=false in the groupplot options, so this would happen. Make it clip=true. If you had any other paths (\draw, \node etc.) that went outside the axis limits, you could add clip mode=individual to enable clipping of plot lines but not other paths within the axis. That is not needed here however.



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