绘制两个 x 轴和一个 y 轴的图,或绘制第二 x 轴上为频率的奈奎斯特图

绘制两个 x 轴和一个 y 轴的图,或绘制第二 x 轴上为频率的奈奎斯特图

我的目标是在具有一个 y 轴和两个 x 轴的坐标系中绘制数据。

现在我正在这样做:

\documentclass[paper=a4,ngerman,xcolor=dvipsnames]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[]{pgfplots}
\usepackage[]{tikz}
\usepackage{siunitx}    

\pgfplotscreateplotcyclelist{mycolorlist}{
blue!01!green,every mark/.append style={fill=blue!10!black},mark=none\\
}
\pgfplotscreateplotcyclelist{mycolorlist2}{
blue!70!green,every mark/.append style={fill=blue!10!black},mark=none\\
}

\pgfplotsset{compat=1.9}
\pgfplotsset{every axis label/.append style={font=\large}}
\pgfplotsset{every tick label/.append style={font=\large}}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
grid=both, 
axis equal,
width=12cm, 
height=9cm,
xtick pos=left,
ytick pos=left,    
xlabel={x1}, ylabel={y1}, 
legend style={at={(0.97,0.03)},anchor=south east, cells={anchor=west}},
legend style={font=\footnotesize},
cycle list name=mycolorlist,
]
\addplot [] coordinates {(2.72E+03,-4.55E+02)(4.68E+03,-1.19E+03)(1.14E+04,-3.17E+03)};
\legend{Zyklus 0}
\end{axis}

\begin{semilogxaxis}[
width=12cm,
height=9cm,
cycle list name=mycolorlist2,
axis x line*=top,
xlabel={x2}     
]
\addplot coordinates {(1.26E+07,-4.55E+02) (2.00E+05,-1.19E+03)(2.00E+02,-3.17E+03)};
\end{semilogxaxis}
\end{tikzpicture}
\end{figure}
\end{document}

结果是: 在此处输入图片描述

我绘制了 x1(底部的 x 轴)的值与 y1 的值的关系图,还绘制了 x2(顶部)与 y1 的关系图。因此有两个问题。

第一的: y 轴上应该只有 x1 对应 y1 的数字。那么我该如何“删除”其他数字呢?

第二: 我必须使用 axis equalx1 对应 y1 但这会导致两条线之间发生偏移。在正确的代码中,它们应该具有相同的起点和终点(如果删除axis equal,它们会具有相同的起点和终点,但这是不允许的)。

以下是部分数据mydata.txt

x1|              y1|               x2

2,72E+03|        -4,55E+02|        1,26E+07

4,68E+03|        -1,19E+03|        2,00E+05

1,14E+04|        -3,17E+03|        2,00E+02

我只是使用“|”作为列的分隔符。

感谢您的帮助!

答案1

似乎我忘了重新回顾一下这个问题。很难说这是否有帮助,因为你的例子只重现了其中一个问题。如果你自己解决了这个问题,可以考虑自己发布一个答案。

反正:

  1. 在第二个轴上添加axis y line=none。或者axis y line=right,将这些数字放在轴的右侧。另一种可能性是ytick=\empty第二个轴。

  2. 我无法测试这一点,因此这只是瞎猜,但也许enlarge x limits明确设置两个轴会有所帮助。例如enlarge x limits=0.1,或enlarge x limits={abs=5mm}

在此处输入图片描述

\documentclass[paper=a4,ngerman,xcolor=dvipsnames]{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{siunitx}    

\pgfplotscreateplotcyclelist{mycolorlist}{
blue!01!green,every mark/.append style={fill=blue!10!black},mark=none\\
}
\pgfplotscreateplotcyclelist{mycolorlist2}{
blue!70!green,every mark/.append style={fill=blue!10!black},mark=none\\
}

\pgfplotsset{compat=1.9}
\pgfplotsset{every axis label/.append style={font=\large}}
\pgfplotsset{every tick label/.append style={font=\large}}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
grid=both, 
axis equal,
width=12cm, 
height=9cm,
xtick pos=left,
ytick pos=left,    
xlabel={x1}, ylabel={y1}, 
legend style={at={(0.97,0.03)},anchor=south east, cells={anchor=west}},
legend style={font=\footnotesize},
cycle list name=mycolorlist,
enlarge x limits=0.1
]
\addplot [] coordinates {(2.72E+03,-4.55E+02)(4.68E+03,-1.19E+03)(1.14E+04,-3.17E+03)};
\legend{Zyklus 0}
\end{axis}

\begin{semilogxaxis}[
width=12cm,
height=9cm,
cycle list name=mycolorlist2,
axis x line*=top,
axis y line=none,% or right
enlarge x limits=0.1,
xlabel={x2}     
]
\addplot coordinates {(1.26E+07,-4.55E+02) (2.00E+05,-1.19E+03)(2.00E+02,-3.17E+03)};
\end{semilogxaxis}
\end{tikzpicture}
\end{figure}
\end{document}

答案2

您可以使用 bodegraph 包 -http://mirror.utexas.edu/ctan/graphics/pgf/contrib/bodegraph/bodegraph.pdf(见第 15 页至最后)

法语文档

相关内容