Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

So my question in general is what is the method to change the precise area of the rectangle used in pgf plots? Yes, to make it larger ...

MWE: a typical bar chart

\documentclass{standalone}\usepackage{pgfplots}
\usetikzlibrary{patterns}\begin{document}%
\begin{tikzpicture}%
\pgfplotsset{every axis legend/.append style={width=40pt,height=30pt,at={(0.96,0.72)},% (0.96,0.72) |-> (1,0.8) defaults this
anchor=south east}}%
\begin{axis}[grid=major,ybar,
width=384pt,x tick style={ultra thick, draw=black},height=384pt,y tick style={ultra thick, draw=black},legend image code/.code={\draw[#1] (-4pt,-4pt) rectangle (14pt,14pt);}]
\addplot[fill=blue,draw=black,point meta=y,
    every node near coord/.style={inner ysep=8pt},
    error bars/.cd,y dir=both,y explicit] table [y error=error] {%
    x   y       error    label
    1   30  2           1};
 \draw ({rel axis cs:0,0}|-{axis cs:0,0}) -- ({rel axis cs:1,0}|-{axis cs:0,0});
 \legend{\raisebox{8pt}{blah},%
 }\end{axis}\end{tikzpicture}\end{document}

edit:

If the legend is basically a matrix, then the separation of entries and the distributed height can be increased, but what about adding a thick white border? (Assume I put in draw=none inside legend style.) How does one increase the white space horizontal from the left and the right of the matrix entries, while keeping them were they are, so the box becomes larger but they do not move? Also from the top and the bottom, while keeping the matrix entries in place. Is it possible, or would this require drawing a white rectangle behind the legend to do this, because no parameter can do this automatically in the legend box itself?

share|improve this question
    
Also, I did not find by searching the particular parameters but I must assume there are some built in. width and height did not compile, though they work for the axis itself. –  Guido Jorg Jul 27 at 9:51

1 Answer 1

up vote 6 down vote accepted

Legend box is a TikZ matrix so matrix node options apply to it.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{tikzpicture}%
\begin{axis}[legend style={minimum height=3cm,column sep=4cm}]
\addplot {rand};\legend{label}
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
How does one increase the white space horizontal from the left and the right of the matrix entries? And also from the top and the bottom, while keeping the matrix entries in place. Is it possible, or would this require drawing a white rectangle behind the legend to do this? –  Guido Jorg Jul 27 at 10:56
    
Actually tried adding a box with \fill[red] (0.5,0.5) rectangle (1,1); in the code, but it does not show up. What is required to get it to show up when pgfplot is used, above the grid and plots but below the legend? –  Guido Jorg Jul 27 at 11:11
    
@GuidoJorg Use inner xsep,inner ysep and inner sep keys (for both at the same) time. Also add line width=1mm –  percusse Jul 27 at 12:53
    
yes, that did it, after adding white to the parameters of the legend itself giving it a thick white border, and then putting \color{black} inside the legend listed items. –  Guido Jorg Jul 27 at 13:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.