4

In the attached picture I have two side-by-side tikzpicture, and I wish to use the vertical coordinates of the red dots in the left tikzpicture on the right one.

enter image description here

What is the correct way to do so? (My code appears below.)

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through,backgrounds}

\tikzset{
    dot/.style = {circle, fill=black, inner sep=0mm, minimum size=1mm},           
}


\begin{document}
\newcommand{\hx}{\hat{x}}
\begin{tikzpicture}[scale=1.5]

\tikzstyle{emptydot}=[fill=white,thin,
inner sep=0pt,minimum size=1.5mm]

\newcommand\ep{1.5}
\newcommand\dist{1.6}

\newcommand\done{255}
\newcommand\dpone{75}



\newcommand\dtwo{225}
\newcommand\dptwo{45}

\newcommand\none{95}
\newcommand\npone{265}

\draw (0,0) circle (1cm);

%line B1
\node (B1) at (\done:\ep cm) [emptydot] {};
\node (B1b) at (\dpone:\ep cm) [emptydot] {};
\draw (\done:\dist cm) node {{$A_1^{-}$}};
\draw [name path=B1--B1b] (B1) -- (B1b);

%line B2
\node (B2) at (\dtwo:\ep cm) [emptydot] {};
\node (B2b) at (\dptwo:\ep cm) [emptydot] {};
\draw (\dtwo:\dist cm) node {{$A_2^{+}$}};
\draw [name path=B2--B2b] (B2) -- (B2b);
\node (n1) at (\none:\ep cm) [emptydot] {};
\node (n1b) at (\npone:\ep cm) [emptydot] {};
\draw [dashed,name path=n1--n1b] (n1) -- (n1b);

%intersections

\path [name intersections={of=B1--B1b and n1--n1b,by=C1}];
\node [dot,fill=red,inner sep=1pt,label=180:{\small $c_1$}] at (C1) {};
\path [name intersections={of=B2--B2b and n1--n1b,by=C2}];
\node [dot,fill=red,inner sep=1pt,label=180:{\small $c_2$}] at (C2) {};


\end{tikzpicture}
\begin{tikzpicture}
\draw (0,1) -- (0,5.2);


\newcommand\cby{2.86}
\newcommand\ccy{3.3}
\newcommand\xa{0.}

\node [dot,label=left:{same height as $c_1$}] at (\xa,\cby) {};
\node [dot,label=left:{same height as $c_2$}] at (\xa,\ccy) {};

\end{tikzpicture}
\end{document}
1
  • 1
    As you want both figures side by side, can they be inside the same tikzpicture?
    – Ignasi
    Jan 17, 2017 at 18:35

1 Answer 1

3

If both tikzpictures should be side by side, may be we can draw both inside one tikzpicture but using different scopes.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through,backgrounds}

\tikzset{
    dot/.style = {circle, fill=black, inner sep=0mm, minimum size=1mm},           
}


\begin{document}
\newcommand{\hx}{\hat{x}}
\begin{tikzpicture}[scale=1.5]

\tikzstyle{emptydot}=[fill=white,thin,
inner sep=0pt,minimum size=1.5mm]

\newcommand\ep{1.5}
\newcommand\dist{1.6}

\newcommand\done{255}
\newcommand\dpone{75}

\newcommand\dtwo{225}
\newcommand\dptwo{45}

\newcommand\none{95}
\newcommand\npone{265}

\draw (0,0) circle (1cm);

%line B1
\node (B1) at (\done:\ep cm) [emptydot] {};
\node (B1b) at (\dpone:\ep cm) [emptydot] {};
\draw (\done:\dist cm) node {{$A_1^{-}$}};
\draw [name path=B1--B1b] (B1) -- (B1b);

%line B2
\node (B2) at (\dtwo:\ep cm) [emptydot] {};
\node (B2b) at (\dptwo:\ep cm) [emptydot] {};
\draw (\dtwo:\dist cm) node {{$A_2^{+}$}};
\draw [name path=B2--B2b] (B2) -- (B2b);
\node (n1) at (\none:\ep cm) [emptydot] {};
\node (n1b) at (\npone:\ep cm) [emptydot] {};
\draw [dashed,name path=n1--n1b] (n1) -- (n1b);

%intersections

\path [name intersections={of=B1--B1b and n1--n1b,by=C1}];
\node [dot,fill=red,inner sep=1pt,label=180:{\small $c_1$}] at (C1) {};
\path [name intersections={of=B2--B2b and n1--n1b,by=C2}];
\node [dot,fill=red,inner sep=1pt,label=180:{\small $c_2$}] at (C2) {};

\begin{scope}[xshift=4cm]
\draw (0,2) -- (0,-2) coordinate (aux);

\node[dot, ,label=left:{same height as $c_1$}] at (C1-|aux) {};
\node[dot, ,label=left:{same height as $c_2$}] at (C2-|aux) {};

\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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