xlabel 中的不同颜色(tikz latex pgfplot)

xlabel 中的不同颜色(tikz latex pgfplot)

我想更改 pgf 图中 x 标签部分的颜色。

\begin{figure}[h!]
\begin{tikzpicture}
\begin{axis}[xtick pos=left,legend pos=south east, xlabel style={yshift=-0.5cm}, xlabel ={Anzahl \& Name},ylabel = {Treffer}, xmin=0, xmax=24 , xtick={1,..., 23}, width=16cm, height = 7cm, extra x ticks ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}, extra x tick labels={24,20,29,7,21,9,23,6,17,14,28,3,15,22,4,1,25,26,18,13,10,30,2}, every extra x tick/.append style={yshift=-5mm, color = orange}, legend entries={only marks,{only marks, sharp plot}}]
% minPlot 
\addplot + [blue, dotted, thick, mark size= 1pt, mark = *,mark options=solid] coordinates
{(1,0.152459)(2,0.19071)(3,0.21571)(4,0.298458)(5,0.33718)(6,0.442662)(7,0.469424)(8,0.469424)(9,0.469424)(10,0.501985)(11,0.501985)(12,0.501985)(13,0.497316)(14,0.501985)(15,0.533835)(16,0.581562)(17,0.581562)(18,0.581562)(19,0.577033)(20,0.581562)(21,0.581562)(22,0.58665)(23,0.58665)};
\addlegendentryexpanded{Minimum}
% maxPlot 
\addplot + [orange, dotted, thick, mark size= 1pt, mark = *,mark options=solid] coordinates
{(1,0.241773)(2,0.320601)(3,0.425313)(4,0.511024)(5,0.572628)(6,0.57816)(7,0.602931)(8,0.613661)(9,0.714107)(10,0.696967)(11,0.69255)(12,0.740246)(13,0.715829)(14,0.735829)(15,0.76873)(16,0.770363)(17,0.791052)(18,0.795816)(19,0.775127)(20,0.795816)(21,0.800581)(22,0.800581)(23,0.795816)};
\addlegendentryexpanded{Maximum}
%totalPlot
\addplot + [dgreen, thick,  mark = *,mark options=solid] coordinates
{(1,0.187953)(2,0.238798)(3,0.295548)(4,0.404494)(5,0.447399)(6,0.518079)(7,0.545772)(8,0.550308)(9,0.578256)(10,0.603746)(11,0.604403)(12,0.621954)(13,0.623214)(14,0.634123)(15,0.655456)(16,0.669676)(17,0.680026)(18,0.680491)(19,0.667123)(20,0.676951)(21,0.681641)(22,0.690181)(23,0.697706)};
\addlegendentryexpanded{Durchschnitt}
\end{axis}
\end{tikzpicture}
\caption{Plot}
\end{figure}

正如您在图片中看到的,我有一些 xtra x 刻度标签,其颜色与 oder x 刻度标签不同。在 x 标签中,我为 x 刻度标签和额外的 x 刻度标签提供了定义。要查看哪个定义属于哪个 x 刻度标签,我想更改 x 标签“名称”的第二部分的颜色。

阴谋

答案1

\textcolor在其他需要彩色单词的情况下,您可以使用as,例如

xlabel ={Anzahl \& \textcolor{orange}{Name}}

相关内容