istogram pgfplots 내 라벨 색상 변경

istogram pgfplots 내 라벨 색상 변경

다음 코드 조각이 주어졌습니다.

\begin{frame}
    \titlesub
        \pgfplotsset{compat=1.9}
        \centering
        \begin{tikzpicture}
        \begin{axis}[
        width=0.9\textwidth,
        height=0.9\textheight,
        ybar stacked,
        ymin=0,
        enlarge y limits={upper, value=0.2},
        enlarge x limits = 0.2,
        bar width = 1 cm,
        legend style={at={(1.1, 1)},
            anchor=north,legend columns=1},
        ylabel={CPU time (s)},
        symbolic x coords={Run 1, Run 2, Run 3, Reference},
        xtick=data,
        nodes near coords,
        legend style={/tikz/every even column/.append style={column sep=0.5cm}}]
        %nodes near coords align={horizontal},
        ]
        \addplot [fill = POLIMIblue] coordinates  {(Run 1, 426) (Run 2, 387) (Run 3, 446) (Reference, 614) };
        \addplot [fill = col2] coordinates  {(Run 1, 1182) (Run 2, 725) (Run 3, 1517) (Reference, 951) };
        \legend{Setup, Solve}
        \end{axis}
        \end{tikzpicture}
\end{frame}

426/387/446/614(흰색) 및 1182/725/1517/951(다른 색상) 라벨의 색상을 어떻게 변경할 수 있습니까?

답변1

당신이 사용할 수있는 every node near coord/.style={green}.

\documentclass{beamer}
\usepackage{pgfplots}
\begin{document}
\begin{frame}
        \pgfplotsset{compat=1.9}
        \centering
        \begin{tikzpicture}
        \begin{axis}[
        width=0.9\textwidth,
        height=0.9\textheight,
        ybar stacked,
        ymin=0,
        enlarge y limits={upper, value=0.2},
        enlarge x limits = 0.2,
        bar width = 1 cm,
        legend style={at={(1.1, 1)},
            anchor=north,legend columns=1},
        ylabel={CPU time (s)},
        symbolic x coords={Run 1, Run 2, Run 3, Reference},
        xtick=data,
        nodes near coords,
        legend style={/tikz/every even column/.append style={column sep=0.5cm}}]
        %nodes near coords align={horizontal},
        ]
        \addplot [fill = blue,every node near coord/.style={white}] coordinates  {(Run 1, 426) (Run 2, 387) (Run 3, 446) (Reference, 614) };
        \addplot [fill = red,every node near coord/.style={green}] coordinates  {(Run 1, 1182) (Run 2, 725) (Run 3, 1517) (Reference, 951) };
        \legend{Setup, Solve}
        \end{axis}
        \end{tikzpicture}
\end{frame}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보