更改 pgfplot 中特定标签的文本格式

更改 pgfplot 中特定标签的文本格式

在此图中,我想更改 x 轴上标签的颜色。例如,我想更改集合1变成橙色。只需 即可完成\textcolor{orange}{Set1},如代码所示。但此刻我对其他标签也做了同样的事情,例如集合2,它不再编译了!

\documentclass[]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture} [trim axis left,trim axis right]
    \tikzset{every pin/.style={pin distance=0.1em,font=\small}}
    \begin{axis}[
        width = \textwidth, height = 5cm,
        ybar,
        ymax=1000,
        ymode=log,
        log basis y={10},
        log ticks with fixed point,
        legend columns = -1, % Horizontal legend
        legend style={anchor=south east,draw=none,fill=none,at={(current axis.north east)},font=\scriptsize},
        symbolic x coords = {\textcolor{orange}{Set1}, Set2, Set3},
        xtick = {\textcolor{orange}{Set1}, Set2, Set3},
        xticklabel style = { rotate = 45, anchor = north east },
        enlarge x limits = 0.08,
        ylabel = {total runtime (ms)},
        bar width = 1mm,
        ]
        \addplot coordinates {(\textcolor{orange}{Set1}, 723.7) (Set2, 721.728)};
        \addplot coordinates {(\textcolor{orange}{Set1}, 199.424) (Set2, 195.702)};
        \addplot coordinates {(\textcolor{orange}{Set1}, 56.3) (Set2, 53.136) (Set3, 55.655)};
        \addplot coordinates {(\textcolor{orange}{Set1}, 34.5) (Set2, 34.559) (Set3, 33.915)};
    \end{axis}
\end{tikzpicture}
\end{document}

对这个奇怪的问题有什么想法吗?

在此处输入图片描述

相关内容