gpt4 book ai didi

plot - Latex - 尝试收集波德图

转载 作者:行者123 更新时间:2023-12-02 01:32:06 28 4
gpt4 key购买 nike

我正在尝试设置一个带有两个 y 轴的图,一个波德图,在同一张图中包含振幅和相位。我使用带有\begin{axis} 和\addplot 的 tikzpicture 包来叠加两个图形。好吧,至少那是我的想法……我的问题是我似乎无法控制图表。我无法为轴设置固定间隔,无法控制绘图线的颜色/样式。请指出我在尝试制作博德图时是否有什么不对劲的地方。特别是,如何设置线条的样式,一根虚线,一根实线?

    \begin{figure}[H]
\centering
\begin{minipage}{0.9 \textwidth}

\begin{tikzpicture}

%%% AMPLITUDE
\begin{axis}[
width=340pt,
height=180pt,
xlabel=Frequency,
xmode = log,
ylabel=Amplitude [dB],
axis x line=bottom,
axis y line=left,
% xmin=10, xmax=1000000,
% ylabel near ticks,
legend pos= south west,
font=\scriptsize,
legend style={font=\scriptsize,draw=none,fill=none}
]


\addplot table [color=black, mark=none,dotted,y=$amp$, x=freq, font=\scriptsize]{amp.dat};
\addlegendentry{$Amplitude$ }

\end{axis}

%%% PHASE
\begin{axis}[
width=340pt,
height=180pt,
% xmin=10, xmax=1000000,
hide x axis,
axis y line=right,
xmode = log,
ylabel=Phase [deg],
% ymin=-300, ymax=-120,
% ylabel near ticks,
legend pos= north east,
font=\scriptsize,
legend style={font=\scriptsize,draw=none,fill=none}
]


\addplot table [mark=none,dashed, y=$phase$, x=freq]{phase.dat};
\addlegendentry{$Phase$ }

\end{axis}

\end{tikzpicture}





\caption{A Bode-plot of the common source gain stage.}
\label{fig:cg_sweep}
\end{minipage}
\end{figure}

如果需要,这里有一些情节的测试数据:https://dl.dropboxusercontent.com/u/43498716/cg_sweep.dat

谢谢!

最佳答案

这就是您要实现的目标吗?

enter image description here

这是一个pgfplots解决方案。

设置间隔的示例:xmin=10, xmax=1000000, ymin=10, ymax=35, ...

设置绘图线条颜色和样式的示例:\addplot[红色,虚线] ...

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

\begin{document}

\begin{tikzpicture}
\pgfplotsset{set layers}
\begin{axis}[
xmode=log,
xmin=10, xmax=1000000,
ymin=10, ymax=35,
scale only axis,
axis y line*=left,
xlabel=Frequency,
ylabel={Amplitude [dB]},
]
\addplot[blue, solid] table[x=freq,y=$amp$] {cg_sweep.dat};
\label{aplot}
\end{axis}
\begin{axis}[
xmode=log,
xmin=10, xmax=1000000,
ymin=-290, ymax=-140,
scale only axis,
axis y line*=right,
axis x line=none,
ylabel={Phase [deg]},
]
\addlegendimage{/pgfplots/refstyle=aplot}\addlegendentry{$Amplitude$}
\addplot[red, dashed] table[x=freq,y=$phase$] {cg_sweep.dat};
\addlegendentry{$Phase$ }
\end{axis}
\end{tikzpicture}

\end{document}

关于plot - Latex - 尝试收集波德图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33522943/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com