在另一个 tikzpicture 中使用一个 tikzpicture 的坐标

在另一个 tikzpicture 中使用一个 tikzpicture 的坐标

在附图中我有两张并排的图片tikzpicture,我希望在tikzpicture右边的图片上使用左边红点的垂直坐标。

在此处输入图片描述

正确的做法是什么?(我的代码如下所示。)

\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

如果两者tikzpictures应该并排,也许我们可以在一个里面绘制两者tikzpicture,但使用不同的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}

在此处输入图片描述

相关内容