极轴图中的误差线

极轴图中的误差线

我正在尝试为 y 数据点创建一个带有误差线的极轴图。我尝试了与error bars/.cd轴图类似的方法,但结果非常混乱。作为背景,x 数据是角度,y 数据是半径。

目前的结果

我在 pgfplots 中找不到其他方法,还是我做错了?我的代码如下:

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat = newest, error bars/y explicit}
\usepgfplotslibrary{polar}

\begin{document}

\begin{tikzpicture}
\begin{polaraxis}
[
    /pgf/number format/use comma,
    xmin = 0, xmax = 360,
    ymin = 30, ymax = 110,
    grid = both,
    major grid style = gray!60,
    minor grid style = gray!10,
    minor tick num = 3,
    yticklabel style = {yshift = -4.65cm},
    y axis line style = {yshift = -4.77cm},
    ytick style = {yshift = -4.77cm},
    legend cell align = left,
    legend style = {at = {(0.25,-0.22)}} 
]
% Adding plot from data
\addplot+
[
    blue!70!yellow,
    only marks,
    mark = square*,
    mark options = {fill = blue!70!yellow},
    mark size = 0.75pt,
    error bars/.cd,
    y dir = both
]           
    coordinates{ (0.0, 91.32)   +-  (0, 2.58)
                    (15.0, 91.83)   +-  (0, 2.61)
                    (30.0, 90.90)   +-  (0, 2.55)
                    (45.0, 90.56)   +-  (0, 2.53)
                    (60.0, 90.98)   +-  (0, 2.56)
                    (75.0, 90.98)   +-  (0, 2.51)
                    (90.0, 91.06)   +-  (0, 2.56)
                   };

\end{polaraxis}
\end{tikzpicture}

\end{document}

答案1

您可以使用如下箭头图:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{pgfplotstable}
\usepgfplotslibrary{polar}
\begin{document}
\begin{tikzpicture}
\pgfplotstableread{
x y e
60.0 85 3
55.0 88 3
50.0 90 5 
55.0 96 3
65.0 94 3
86.0 91 3
}\loadedtable %data changed
\begin{polaraxis}[
xmin=0, xmax=360,
ymin=30, ymax=110,
grid=both,
grid style=gray!20,
]
\addplot[
blue,
forget plot,
quiver={u=0,v=2*\thisrow{e}},
|-|,
] table[y expr={\thisrow{y}-\thisrow{e}}]{\loadedtable};

\addplot+[
only marks,
mark size=0.75pt,
] table{\loadedtable};
\node[align=left, font=\tiny] at (82,80) {I can't\\shake him!};
\end{polaraxis}
\end{tikzpicture}
\end{document}

带径向误差线的极坐标图

相关内容