tikz pgfplot 中的标题框显示错误的 RGB 颜色?

tikz pgfplot 中的标题框显示错误的 RGB 颜色?

我有以下图表:

在此处输入图片描述

由以下代码创建:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}

\begin{figure}[h] 
\caption{Time series median of APE based on combinatorial selection schemes}
\label{Figure.TimeseriesofAPE}
\centering 
\begin{tikzpicture}   
\begin{axis}[width=14cm,height=8cm,
            ylabel={Absolute Percentage Error},
            xmin=2003.5,
            xmax=2018.5,
            ymin=15,
            ymax=35,
            xtick=data,
            xticklabel style=
            {/pgf/number format/1000 sep=,rotate=40},
            ytick={15, 20, 25, 30, 35},
            axis background/.style={fill=gray!5},
            legend style={fill=gray!5},
            xtick pos=lower,ytick pos=left,
            yticklabel=\pgfkeys{/pgf/number format/.cd,fixed,precision=0,zerofill}\pgfmathprintnumber{\tick}\%,
             title=\fcolorbox{black}{rgb:red,0;green,48;blue,133}{\makebox[12.2cm]{\textcolor{white}{\textbf{EV/EBIT}}}},
             title style={yshift=-0.34cm},
]
            \addplot [semithick,mark=square*,black,mark options={scale=1.2}] coordinates {
(2004,23.9477345892197)
(2005,24.0195465335992)
(2006,20.6276481251735)
(2007,18.265284388086)
(2008,21.8111180034732)
(2009,24.2629967323528)
(2010,22.2193898469998)
(2011,23.4662001690915)
(2012,22.3983479598189)
(2013,21.6518435739983)
(2014,20.7295962241899)
(2015,21.5151016657556)
(2016,22.728213671688)
(2017,20.6614535846647)
(2018,23.2079687708666)


    };
\addlegendentry{SBP Plus SARD}
\addplot[semithick,mark=*,red,mark options={scale=1.2}]
coordinates{
(2004,30.6453384436133)
(2005,25.9071572285215)
(2006,21.5368656549373)
(2007,23.1619489291921)
(2008,22.716278332465)
(2009,26.6295451295127)
(2010,25.7656563953101)
(2011,21.0579081996823)
(2012,23.9734983213042)
(2013,27.0328903793312)
(2014,23.5204904251705)
(2015,24.5540581415406)
(2016,27.393772936285)
(2017,23.77644107908)
(2018,24.9426613487672)

    };
\addlegendentry{GICS Plus SARD}    
            \end{axis}
    \end{tikzpicture}
\end{figure}
\end{document}

现在,我已将 RGB 指定为:Red=0, Green=47, Blue=135。但是,这种颜色似乎不太对劲,因为我对章节和部分标题使用相同的 RGB 规范,如下所示:

在此处输入图片描述

它具有 RGB 规范,如0,47,135。发生了什么事?

答案1

本网站用户之所以坚持要求提供完整的最小工作示例,是因为否则我们很可能会浪费大量时间,因为不清楚您是如何获得结果的。您是如何获得结果的?文章文档中的一章。无论如何,这都是产生一致着色的东西。

\documentclass{book}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\definecolor{obscureblue}{RGB}{39,70,182}
% borrowed from https://tex.stackexchange.com/a/1477/121799
\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\normalfont\Huge\bfseries\color{obscureblue}}
  {\chaptertitlename\ \thechapter}{20pt}{\Huge}
\begin{document}
\chapter{Discussion}
\begin{figure}[h] 
\caption{Time series median of APE based on combinatorial selection schemes}
\label{Figure.TimeseriesofAPE}
\centering 
\begin{tikzpicture}   
\begin{axis}[width=14cm,height=8cm,
            ylabel={Absolute Percentage Error},
            xmin=2003.5,
            xmax=2018.5,
            ymin=15,
            ymax=35,
            xtick=data,
            xticklabel style=
            {/pgf/number format/1000 sep=,rotate=40},
            ytick={15, 20, 25, 30, 35},
            axis background/.style={fill=gray!5},
            legend style={fill=gray!5},
            xtick pos=lower,ytick pos=left,
            yticklabel=\pgfkeys{/pgf/number format/.cd,fixed,precision=0,zerofill}\pgfmathprintnumber{\tick}\%,
             title style={yshift=-0.34cm,fill=obscureblue,text
             width=12.2cm,text=white,font=\bfseries,align=center},
             title=EV/EBIT,
]
\typeout{\pgfkeysvalueof{/pgfplots/width}}
            \addplot [semithick,mark=square*,black,mark options={scale=1.2}] coordinates {
(2004,23.9477345892197)
(2005,24.0195465335992)
(2006,20.6276481251735)
(2007,18.265284388086)
(2008,21.8111180034732)
(2009,24.2629967323528)
(2010,22.2193898469998)
(2011,23.4662001690915)
(2012,22.3983479598189)
(2013,21.6518435739983)
(2014,20.7295962241899)
(2015,21.5151016657556)
(2016,22.728213671688)
(2017,20.6614535846647)
(2018,23.2079687708666)


    };
\addlegendentry{SBP Plus SARD}
\addplot[semithick,mark=*,red,mark options={scale=1.2}]
coordinates{
(2004,30.6453384436133)
(2005,25.9071572285215)
(2006,21.5368656549373)
(2007,23.1619489291921)
(2008,22.716278332465)
(2009,26.6295451295127)
(2010,25.7656563953101)
(2011,21.0579081996823)
(2012,23.9734983213042)
(2013,27.0328903793312)
(2014,23.5204904251705)
(2015,24.5540581415406)
(2016,27.393772936285)
(2017,23.77644107908)
(2018,24.9426613487672)

    };
\addlegendentry{GICS Plus SARD}    
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

相关内容