
我今天的問題是將電路(主要使用 \draw 繪製)安裝到 Tikz 軸中。
我正在使用 Axis 命令從一組點繪製(使用 \addplot)一條曲線(到目前為止沒有問題),但我無法弄清楚 Tikzpicture 如何處理錨點以及所有這些,以使事情不會變得瘋狂,但留在原地。
為了更清楚起見,以下是我製作 3 個軸的程式碼(如果您願意,可以有 3 個子圖,2 個在頂部,1 個在左下角):
\begin{tikzpicture}[scale=1]
% Vs(ve) graphique
\begin{axis}[name=plot1
]
\addplot[black] table {Fig_ELA2/ELA2_P3_C3/ELA2_P3_C1_PP_CLASSE_B/courbes/vs_ve_out.txt};
\end{axis}
% Vs(wt) graphique
\begin{axis}[name=plot2,at={($(plot1.east)+(1.5cm,0)$)},anchor=west
]
\addplot[black] table {Fig_ELA2/ELA2_P3_C3/ELA2_P3_C1_PP_CLASSE_B/courbes/vs_t_out.txt};
\end{axis}
% Ve(wt) graphique
\begin{axis}[name=plot3,at={($(plot1.south)-(0,1.5cm)$)},anchor=north
]
\addplot[black] table {Fig_ELA2/ELA2_P3_C3/ELA2_P3_C1_PP_CLASSE_B/courbes/ve_t_out.txt};
\end{axis}
% Electrical circuit
\draw
(0,0) node[njfet](J){$J$}
(J.S) to[short,-o] ++(0,-0.1) node[left](S){\tiny S} to [R, l_=$R_S$,-*] (0,-3) node(gnd_rs)[ground]{}
(J.D) to[short,-o] ++(0,0.3) node[left](D){\tiny D} to [R, l=$R_D$] ++(0,2) node[vcc]{\color{green} $V_{CC}$}
(J.G) to[short,-o] ++(-0.1,0) node[above](G){\tiny G}-- ++(-1,0) node(RG){}
;
\coordinate (gnd_rg) at (RG|-gnd_rs);
\draw (RG) to [R, l_=$R_G$,-*] (gnd_rg);
\draw (gnd_rs) to[short,-o] ++(-4,0) node(gnd_ve){};
\draw (gnd_rs) to[short,-*] ++(1,0) node(gnd_cs){} to[short,-o] ++(2,0) node(gnd_vs){};
\coordinate (ve) at (gnd_ve|-J.G);
\draw (ve) to[C,l=$C_{Le}$,o-*] (RG);
\coordinate (vs) at (gnd_vs|-D);
\draw (D) to[C,l=$C_{Ls}$,-o] (vs);
\coordinate (cs) at (S-|gnd_cs);
\draw (S) -- (cs) to[C,l=$C_S$,] (gnd_cs);
\draw[-triangle 45, red] (gnd_vs) -- (vs) node[right,pos=0.5]{$v_s(t)$};
\draw[-triangle 45, red] (gnd_ve) -- (ve) node[left,pos=0.5]{$v_e(t)$};
\end{tikzpicture}
我很抱歉沒有提供曲線供您測試,我猜您可以製作愚蠢的曲線(或者根本不添加曲線)。
那麼有沒有一種方法可以將電路設為絕對,並使其在 CSS 中表現得像絕對(因此不符合流程)。
感謝您的幫助 !
答案1
您應該始終嘗試發布獨立的範例,以便想要提供幫助的人可以在不猜測您的序言或定義的情況下完成此操作。儘管如此,這是一個選擇——請注意:
- 在你的電路中,你只有一個絕對座標,即
(0,-3)
第一行中的 ,我修復了它(並使你的電路無法翻譯)。 - 即便如此,電路還是很大,所以我根據
scope
環境對其進行了縮放。
所以你可以做這樣的事情(手動調整++(6,-5)
;可以做更自動的事情,但那是另一個故事了,改天會講到......)
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[scale=1]
% Vs(ve) graphique
\begin{axis}[name=plot1
]
\addplot[black] {sin(x)};
\end{axis}
% Vs(wt) graphique
\begin{axis}[name=plot2,at={($(plot1.east)+(1.5cm,0)$)},anchor=west
]
\addplot[black] {cos(x)};
\end{axis}
% Ve(wt) graphique
\begin{axis}[name=plot3,at={($(plot1.south)-(0,1.5cm)$)},anchor=north
]
\addplot[black] {x};
\end{axis}
% Electrical circuit
\begin{scope}[scale=0.8, transform shape]
\draw
(plot1.south east) ++(6,-5) node[njfet](J){$J$}
(J.S) to[short,-o] ++(0,-0.1) node[left](S){\tiny S} to [R, l_=$R_S$,-*] ++(0,-3) node(gnd_rs)[ground]{}
(J.D) to[short,-o] ++(0,0.3) node[left](D){\tiny D} to [R, l=$R_D$] ++(0,2) node[vcc]{\color{green} $V_{CC}$}
(J.G) to[short,-o] ++(-0.1,0) node[above](G){\tiny G}-- ++(-1,0) node(RG){}
;
\coordinate (gnd_rg) at (RG|-gnd_rs);
\draw (RG) to [R, l_=$R_G$,-*] (gnd_rg);
\draw (gnd_rs) to[short,-o] ++(-4,0) node(gnd_ve){};
\draw (gnd_rs) to[short,-*] ++(1,0) node(gnd_cs){} to[short,-o] ++(2,0) node(gnd_vs){};
\coordinate (ve) at (gnd_ve|-J.G);
\draw (ve) to[C,l=$C_{Le}$,o-*] (RG);
\coordinate (vs) at (gnd_vs|-D);
\draw (D) to[C,l=$C_{Ls}$,-o] (vs);
\coordinate (cs) at (S-|gnd_cs);
\draw (S) -- (cs) to[C,l=$C_S$,] (gnd_cs);
\draw[->, red] (gnd_vs) -- (vs) node[right,pos=0.5]{$v_s(t)$};
\draw[->, red] (gnd_ve) -- (ve) node[left,pos=0.5]{$v_e(t)$};
\end{scope}
\end{tikzpicture}
\end{document}