TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a follow up question to this one: Use pgfplots \addplot plot coordinates with relative coordinates

Is it also possible to have the relative coordinates across multiple plots?

For example if I take @Jake's answer:

        \addplot table [x = x rel, y=y rel,ignore chars=\%] {
      0 0 %absolute (0,0)
      2 2 %absolute (2,2)
      1 3 %absolute (2,2) + (1,3) = (3,5)
     \addplot table [x = x rel, y=y rel,ignore chars=\%] {
      1 1 %absolute (3,5) + (1,1) = (4,6)
      2 1 %absolute (4,6) + (2,1) = (6,7)

Alternatively it would also suffice to be able to specify in the table that the path between two specific successive coordinates should not be drawn.

share|improve this question
Can you add a little bit of background information about what you're trying to achieve? In this simple example, it's not clear why you would need two different \addplot commands, for example. – Jake Sep 23 '12 at 18:20
I don't want a line between the absolute coordinates (3,5) and (4,6) in my example. So I just tried to use two \addplots – student Sep 23 '12 at 18:21
Could you just manually adjust the first coordinate in the second \addplot command (in this case, using 4 6 instead of 1 1)? – Jake Sep 23 '12 at 20:49
Instead of using the pgfplotstable approach you can use \draw (axis cs: 0,0) -- ++ (axis direction cs: 2,2) -- ++ (axis direction cs:1,3) -- ++ (axis direction cs:1,1) -- ++ (axis direction cs:2,3); which allows you to delete the appropriate --. I'm not sure if this is the direction (pun intended) you want to go though... – cmhughes Sep 23 '12 at 23:22

I guess you want to continue the previous curve with a new one, so I cooked up semi-automatic style but can be automated by placing a node in the end of the previous curve converting its coordinates into axis coordinates and supplying to the next as the initial point.

It mainly abuses the expr accum column type with an initial value. You need to add a zero row before resuming though.


    create on use/x rel/.style={create col/expr={\pgfmathaccuma + \thisrow{0}}},
    create on use/y rel/.style={create col/expr={\pgfmathaccuma + \thisrow{1}}},
    x resume/.style={create on use/xrelr/.style={create col/expr accum={\pgfmathaccuma + \thisrow{0}}{#1}},x=xrelr},
    y resume/.style={create on use/yrelr/.style={create col/expr accum={\pgfmathaccuma + \thisrow{1}}{#1}},y=yrelr},

        \addplot table [x = x rel, y=y rel] {
      0 0
      2 2
      3 4
     \addplot table [x resume = 5, y resume = 6] {
      0 0
      5 -4
      9 3

enter image description here

share|improve this answer

Your Answer


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.