是否可以制作图形,左边有一个线性纵坐标,右边有一个不同的纵坐标但是是对数的?
在下面的 MWE 中,我进行了尝试,但没有成功。我收到以下错误:
**C:\Program Files (x86)\MiKTeX 2.9\tex\latex\pgfplots\pgfplots.sty:227: 段落在 \pgfflt@readlowlevelfloat 完成之前结束。
C:\Program Files (x86)\MiKTeX 2.9\tex\latex\pgfplots\pgfplots.sty:233: 软件包 pgfplots 错误:抱歉,不支持嵌套轴环境。请将内轴环境移至 \end{axis} 下方,并使用对齐选项(例如命名节点,请参阅手册)将其放置在所需位置。
C:\Program Files (x86)\MiKTeX 2.9\tex\latex\pgfplots\pgfplots.sty:233:超出 TeX 容量,抱歉 [输入堆栈大小=5000]。[]]**
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{semilogyaxis}[
axis y line*=left,
y axis style=blue!75!black,
xlabel=vykon (dBm),
ylabel={\textsl{BER} [--]}
]
\addplot[smooth,mark=x,blue]
coordinates{
(-7.740,6.20E-10)
(-8.860,6.38E-10)
(-9,.50,7.51E-10)
(-10.87,1.05E-08)
(-11.92,1.02E-08)
(-12.97,1.63E-10)
(-14.06,2.39E-10)
(-15.15,3.02E-10)
(-16.20,5.89E-10)
(-17.33,1.19E-08)
(-18.50,1.08E-07)
(-19.74,7.93E-07)
(-21.10,6.64E-06)
(-22.55,5.78E-05)
(-24.17,3.56E-04)
};
\end{semilogyaxis}
\begin{axis}[
axis y line*=right,
axis x line=none,
ylabel={\textsl{BER} [--]},
y axis style=red!75!black
]
\addplot[smooth,mark=*,red]
coordinates{
(0,0)
(0.0148,48)
(0.0295,66)
(0.0441,66)
(0.059,45.0)
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您缺少\begin{tikzpicture}
,y axis style
而是y axis line style
,并且第一个图的第三个坐标上有拼写错误:9,.50
应该是9.50
。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
axis y line*=left,
y axis line style=blue!75!black,
xlabel=vykon (dBm),
ylabel={\textsl{BER} [--]}
]
\addplot[smooth,mark=x,blue]
coordinates{
(-7.740,6.20E-10)
(-8.860,6.38E-10)
(-9.50,7.51E-10)
(-10.87,1.05E-08)
(-11.92,1.02E-08)
(-12.97,1.63E-10)
(-14.06,2.39E-10)
(-15.15,3.02E-10)
(-16.20,5.89E-10)
(-17.33,1.19E-08)
(-18.50,1.08E-07)
(-19.74,7.93E-07)
(-21.10,6.64E-06)
(-22.55,5.78E-05)
(-24.17,3.56E-04)
};
\end{semilogyaxis}
\begin{axis}[
axis y line*=right,
axis x line=none,
ylabel={\textsl{BER} [--]},
y axis line style=red!75!black
]
\addplot[smooth,mark=*,red]
coordinates{
(0,0)
(0.0148,48)
(0.0295,66)
(0.0441,66)
(0.059,45.0)
};
\end{axis}
\end{tikzpicture}
\end{document}