PGFPlots 和 Tikz 褪色库存在问题,坐标附近的节点消失且褪色不规则

PGFPlots 和 Tikz 褪色库存在问题,坐标附近的节点消失且褪色不规则

似乎每当我从 Tikz Fading 库中打开 Fading 时,PGFPlots 都无法正确处理 axis 环境的 nodes near coords 参数。我附上了代码和我得到的图像。(虽然有些人可能会认为条形图的淡入淡出不代表任何额外的信息,但它有助于我将观众的注意力转移到没有淡入淡出的部分)。在下面的代码中,红色和黄色图表启用了淡入淡出,而蓝色和绿色图表禁用了淡入淡出。其次,淡入淡出选项似乎是这样的,条形图中的每个条形都不会发生淡入淡出,但一组条形会淡入淡出(例如,红色图)。有没有办法让我可以获得每个条形的淡入淡出,还可以获得 nodes near coords?

\documentclass[12pt]{article}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[margin=1cm]{geometry}
\usepackage{pgfplots}
\usetikzlibrary{patterns,fadings}

\begin{filecontents*}{Total_Histogram.dat}
0.00000000e+00 2.00000000e+00
 5.00000000e-01 0.00000000e+00
 1.00000000e+00 3.00000000e+00
 1.50000000e+00 3.00000000e+00
 2.00000000e+00 4.00000000e+00
 2.50000000e+00 1.00000000e+00
 3.00000000e+00 2.00000000e+00
 3.50000000e+00 1.00000000e+00
 4.00000000e+00 2.00000000e+00
 4.50000000e+00 2.00000000e+00
 5.00000000e+00 3.00000000e+00
 5.50000000e+00 5.00000000e+00
 6.00000000e+00 3.00000000e+00
 6.50000000e+00 4.00000000e+00
 7.00000000e+00 7.00000000e+00
 7.50000000e+00 5.00000000e+00
 8.00000000e+00 4.00000000e+00
 8.50000000e+00 0.00000000e+00
 9.00000000e+00 2.00000000e+00
 9.50000000e+00 2.00000000e+00
 1.00000000e+01 1.00000000e+00
 1.05000000e+01 0.00000000e+00
 1.10000000e+01 3.00000000e+00
 1.15000000e+01 2.00000000e+00
 1.20000000e+01 0.00000000e+00
 1.25000000e+01 0.00000000e+00
 1.30000000e+01 1.00000000e+00
 1.35000000e+01 0.00000000e+00
 1.40000000e+01 0.00000000e+00
 1.45000000e+01 0.00000000e+00
 1.50000000e+01 0.00000000e+00
\end{filecontents*}

\begin{document}
\pagestyle{empty}

\begin{tikzpicture}
    \centering
    \begin{axis}
    [
    width=\textwidth,
    ybar,
    ymin=0,
    xtick=data,
    xticklabel style={rotate=45},
    legend columns=-1,
    nodes near coords,
    every node near coord/.append style={
    rotate=30,
    xshift=1mm,
    inner sep=1pt,
    color=gray
    },
    ytick={0,1,2,3,4,5,6,7},
    ymajorgrids,
    major grid style={thick,white},
    axis on top,
    tick pos=left,
    xlabel=Total Points in Quiz-1,
    ylabel=Number of Students,
    x label style={at={(axis description cs:0.5,-0.05)},anchor=north},
    title={\bf Performance of students in Quiz-1}
    ]

        \addplot+[path fading=east,color=red!30,draw=black,forget plot] table [y index=1,x index=0,skip coords between index={5}{31}]{Total_Histogram.dat};
        \addplot+[path fading=south,color=yellow!30,draw=black,forget plot] table [y index=1,x index=0,skip coords between index={0}{5},skip coords between index={11}{31}]{Total_Histogram.dat};
        \addplot+[color=blue!30,draw=black,forget plot] table [y index=1,x index=0,skip coords between index={0}{11},skip coords between index={17}{31}]{Total_Histogram.dat};
        \addplot+[color=green!30,draw=black] table [y index=1,x index=0,skip coords between index={0}{17}]{Total_Histogram.dat};

        \node [fill=red!30,,decoration={random steps,segment length=6pt,amplitude=2pt},decorate] at (axis cs:0.65,3.75) {Attention};
        \node [fill=yellow!30] at (axis cs:3.5,3.75) {C,D grades};
        \node [fill=blue!30] at (axis cs:7,7.35) {B grade};
        \node [fill=green!30] at (axis cs:11,3.75) {A,S grades};
        \draw [->,blue,ultra thick] (axis cs:5.9,0) -- (axis cs:5.9,6.5) node [anchor=north east,draw=gray,xshift=-1.5mm]{Average=5.9};
        \draw [<->,gray,ultra thick]    (axis cs:-0.1,5.4) -- (axis cs:5.8,5.4) node [anchor=north,midway]{28 Students};
        \draw [<->,gray,ultra thick]    (axis cs:6.0,5.4) -- (axis cs:15,5.4) node [anchor=north,midway]{34 Students};
    \end{axis}

\end{tikzpicture}

\end{document}

pgfplots 中坐标附近的节点不正确的褪色和消失

相关内容