I've drawn a rectangle like this:

\draw[color=orange, fill=orange, opacity=0.1] (Q3term1) rectangle (Q3term2);

and essentially, what I want is to do is stretch the rectangle by 10% horizontally and stretch is vertically by 5%, so something like:

\draw[color=orange, fill=orange, opacity=0.1] ($(1.1,1.05)*(Q3term1)$) rectangle ($(0.9,0.95)*(Q3term1)$);

If there is a way to do it without the calc library, that'd be good too.


  • 1
    Do you want to scale the rectangle about that amount or the coordinates? Commented Aug 30, 2013 at 3:22
  • Wow, yes that's exactly what I want... I can't believe how much I failed at finding this... Thanks. Oh whoops, you change your answer! Well whyat you had was what I wanted. I guess I want to scale the rectangle.
    – user968243
    Commented Aug 30, 2013 at 3:28
  • Yes, I only took a look at your second code line and that can be done without the calc library with xscale and yscale but that does scale the coordinate, not the rectangle. The 0,0 coordinate would also be un-affected by this. There is scale around which you could use to scale around ($(Q3term1)!.5!(Q3term2)$) but this works only for the same scale in both directions. Maybe it can be easier done with a node like in tikz: Can we set the corner coordinates of a rectangle? Commented Aug 30, 2013 at 3:31

1 Answer 1


If you don’t need to specify the corners of the rectangle relatively, you can use a rectangle node for this.

The \pgfpointlineattime{<factor>}{<p1>}{<p2>} macro is the low-level PGF version of ($(<p1>)!<factor>!(<p2>)$) which is also used in the placement of nodes along a straight line with the pos=<factor> option.

If you want to add a specific padding length, you can use the fit library with inner xsep and inner ysep.

The backgrounds library is only used to add a simply grid to the picture.


  from/.code args={#1 to #2}{%
    % The next line sets "at".
      inner sep=+0pt,
      outer sep=+0pt,
      minimum width/.expanded={abs(\the\pgf@x)},
      minimum height/.expanded={abs(\the\pgf@y)}}%
\begin{tikzpicture}[gridded,nodes={orange, draw, fill, fill opacity=.5}]
\path (1,1) coordinate (a)
      (3,4) coordinate (b)
      (4,1) coordinate (a')
      (6,4) coordinate (b');

\node[from=(a) to (b), xscale=1.1, yscale=1.05] {};
\node[fit=(a')(b'), inner xsep=.1cm, inner ysep=.07cm] {};


enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .