如何将表的值索引添加到图表上的某个点?

如何将表的值索引添加到图表上的某个点?

我想将索引值作为标签添加到极坐标梳状图的每个分支中。

我给你我的代码和一张我想要的截图:

\documentclass{minimal}
\usepackage{eurosym}
\usepackage{pgfplots}
\usepackage{fp}

\begin{document}
\pgfplotsset{compat=newest} 
\centering
\begin{tikzpicture}
\begin{polaraxis}[
    visualization depends on=x \as \pgfplotspointx,
    nodes near coords,
    every node near coord/.style={
        rotate=\pgfplotspointx,
        append after command={
            node [
                anchor=south,
                rotate=\pgfplotspointx,
                shift={(axis direction cs:0,(12.75-\pgfplotspointmeta))}
            ] {$\pgfmathprintnumber{\pgfplotspointx}^\circ$}
        }
    },
width=4.2\textwidth,
xmin=-1,xmax=45.01, ymin=12, ymax=15,
title=Displacement 12N,
grid=both,
minor x tick num={4}, 
minor y tick num={1},
]
\addplot+[polar comb ,data cs=cart, mark size=1, mark=asterisk] table {
13.8893888888889    0
13.8875152609215    0.256057893044211
13.8818942709919    0.512013162090311
13.8725256030249    0.767763280177719
13.8594087369111    1.02320591422122
13.8425429585071    1.27823902144993
13.8219273735841    1.53276094524909
13.7975609256787    1.78667051020809
13.7694424177793    2.03986711617976
13.7375705377745    2.29225083115874
13.7019438875704    2.54372248278928
13.6625610157771    2.79418374831654
13.6194204538470    3.04353724279891
13.5725207555396    3.29168660540349
13.5218605395737    3.53853658361110
13.4674385353184    3.78399311516262
13.4092536313646    4.02796340758379
};
\end{polaraxis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

提前非常感谢您!

答案1

\coordindex添加包含的节点every node near coord/.style

every node near coord/.style={
    rotate=\pgfplotspointx,
    append after command={
    node [
        anchor=south,
        rotate=\pgfplotspointx,
        shift={(axis direction cs:0,(12.75-\pgfplotspointmeta))}
    ] {$\pgfmathprintnumber{\pgfplotspointx}^\circ$}
    node [ % this is the index node
        anchor=south,
        rotate=\pgfplotspointx,
        text=black,
        shift={(axis direction cs:0,(13.4-\pgfplotspointmeta))}
    ] {\coordindex}
}

在此处输入图片描述

代码:

\documentclass{scrartcl}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.10}
\begin{document}
\centering
\begin{tikzpicture}
\begin{polaraxis}[
    visualization depends on=x \as \pgfplotspointx,
    nodes near coords,
    every node near coord/.style={
        rotate=\pgfplotspointx,
        append after command={
        node [
            anchor=south,
            rotate=\pgfplotspointx,
            shift={(axis direction cs:0,(12.75-\pgfplotspointmeta))}
        ] {$\pgfmathprintnumber{\pgfplotspointx}^\circ$}
        node [
            anchor=south,
            rotate=\pgfplotspointx,
            text=black,
            shift={(axis direction cs:0,(13.4-\pgfplotspointmeta))}
        ] {\coordindex}
    }
},
width=4.2\textwidth,
xmin=-1,xmax=45.01, ymin=12, ymax=15,
title=Displacement 12N,
grid=both,
minor x tick num={4}, 
minor y tick num={1},
]
\addplot+[polar comb ,data cs=cart, mark size=1, mark=asterisk] table {
13.8893888888889    0
13.8875152609215    0.256057893044211
13.8818942709919    0.512013162090311
13.8725256030249    0.767763280177719
13.8594087369111    1.02320591422122
13.8425429585071    1.27823902144993
13.8219273735841    1.53276094524909
13.7975609256787    1.78667051020809
13.7694424177793    2.03986711617976
13.7375705377745    2.29225083115874
13.7019438875704    2.54372248278928
13.6625610157771    2.79418374831654
13.6194204538470    3.04353724279891
13.5725207555396    3.29168660540349
13.5218605395737    3.53853658361110
13.4674385353184    3.78399311516262
13.4092536313646    4.02796340758379
};
\end{polaraxis}
\end{tikzpicture}
\end{document}

相关内容