Латекс - попробуй собрать сюжет Боде

Я пытаюсь настроить график с двумя осью Y, график Боде с амплитудой и фазой на той же диаграмме. Я использую пакет tikzpicture с \begin{axis} и \addplot для наложения двух графиков. Ну, по крайней мере, это идея... Проблема в том, что я не могу контролировать графики. Я не могу установить фиксированные интервалы для оси, не могу управлять цветом/стилем сюжетных линий. Пожалуйста, укажите, есть ли что-то шаткое в моей попытке построить сюжет Боде. В частности, как задать стиль линиям, одной пунктирной и одной сплошной?

    \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

Спасибо!


person Überfuzz    schedule 04.11.2015    source источник


Ответы (1)


Это то, чего вы пытаетесь достичь?

введите здесь описание изображения

Вот решение pgfplots.

Пример установки интервалов: xmin=10, xmax=1000000, ymin=10, ymax=35, ...

Пример настройки цвета и стиля линии графика: \addplot[red, dashed] ...

\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}
person sergej    schedule 04.11.2015
comment
Да, большое спасибо. (как мне отметить этот вопрос как решенный?) - person Überfuzz; 04.11.2015
comment
@Überfuzz Добро пожаловать. Вы не отмечаете вопросы как решенные, вы отмечаете ответы как принятые (то, что вы сделали), взгляните на тур. - person sergej; 04.11.2015