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.

Is it possible to create interconnected graphs in pgfplots (e.g. common grids), like the picture below?

And, related to the question above, if you have one tikzpicture environment with two axis environments, is it possible to ensure, that both will have exactly the same measure on both x and y axis?

enter image description here

Edit: I tried to write x axis grid manually, but I had problems using foreach. E.g. example below simply does not work (bunch of endcsname errors).

\documentclass{minimal}
\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[samples=505,domain=0:630]
\addplot {cos(x)};
\foreach \i in {180,360,540} {\node (a\i) at (axis cs:\i,0) {};}

\end{axis}
\end{tikzpicture}
\end{document}
share|improve this question
    
add comment

1 Answer

up vote 6 down vote accepted

Concerning the first question (grids which pass through a couple of vertically adjacent axes): this will only work if you move the axes so close to each other that the independent grids touch each other (which means that the drawn axis lines will also touch each other). pgfplots has no builtin solution for this feature.

Concerning the second question (ensure the same unit scales): yes, you can explicitly set the amount of space used for each unit (using x=1cm,y=2cm or something like that, compare the manual), and you can explicitly set the displayed ranges (xmin=0,xmax=5).

share|improve this answer
    
Concerning the first question, since there is no interest for such addition as far as voting is concerned, would it be possible to create vertical grids manually? E.g. would it be possible to e.g. connect point (cs:2,2) of the first graph to the point (cs:2,-2) of the last graph? –  Pygmalion Aug 25 '12 at 12:54
    
yes, I would say so. You would probably need some sort of loop to introduce labelled coordinates inside of the first axis and then, after the last axis, you could probably generate TikZ drawing instructions. Interesting aspects might be \pgfkeysvalueof{/pgfplots/ymax} which expands to the maximum y axis limit (but only inside of an axis) and \draw[/pgfplots/every axis grid] which uses the standard grid style of pgfplots. –  Christian Feuersänger Aug 25 '12 at 13:10
    
I succeeded to create it, using your advices. –  Pygmalion Aug 27 '12 at 15:46
add comment

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.