为何我的图形标签看起来很苍白?

为何我的图形标签看起来很苍白?

我正在尝试使用 pgfplots 绘制图形,但尽管我没有更改文档中的任何颜色,但其标签看起来很苍白。为什么会发生这种情况?我该如何解决?

这是我的代码:

\begin{figure*}
    \centering
    \pgfplotsset{width=11cm}
 \begin{tikzpicture}
 \begin{axis}[ybar,
     x tick label style={rotate=90, anchor=east},
 symbolic x coords={Karate(P), Karate(Rand), Dolphins(P), Dolphins(Rand),Football(P), Football(Rand)},
 %,Jazz(P), Jazz(Rand),Polbooks(P), Polbooks(Rand)
 nodes near coords,
 legend style={at={(0.5,-0.45)},
 anchor=north,legend columns=-1},
 nodes near coords align={vertical},]

\addplot coordinates{(Karate(P),0.378) (Karate(Rand),0.24) (Dolphins(P),0.51) (Dolphins(Rand),0.25) (Football(P),0.566) (Football(Rand),0.23) };
%(Jazz(P),0.356) (Jazz(Rand),0.1) (Polbooks(P),0.5) (Polbooks(Rand),0.21)
 \addplot coordinates{(Karate(P),0.369) (Karate(Rand),0.17) (Dolphins(P),0.47) (Dolphins(Rand),0.19) (Football(P),0.511) (Football(Rand),0.19)};
 %(Jazz(P),0.28) (Jazz(Rand),0.08)(Polbooks(P),0.46) (Polbooks(Rand),0.14)
\legend{$Q_{max}$,$Q_{avg}$}
 \end{axis}
 \end{tikzpicture}    
            \label{FIG:8}
\end{figure*}

它看起来是这样的:

正如你所见,边框和文字都是浅色的

我正在使用 Elsevier 的单列类模板:

\documentclass[a4paper,fleqn,12pt]{cas-sc}
\usepackage[numbers]{natbib}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{algorithm}
\usepackage{pgfplots}
\newgeometry{bindingoffset=0.2in,left=1in,right=1in,top=1in,bottom=1in,footskip=.25in}
\usepackage[noend]{algpseudocode}
\usepackage{tabularx,ragged2e}
\usetikzlibrary{pgfplots.statistics}
\usepackage{subcaption}
\captionsetup{compatibility=false}
\usepackage{lineno}

\begin{document}

% some abstracts and sections



\end{document}

有趣的是,当我将课程从 转换为 时,cas-sc问题cas-dc解决了:

在此处输入图片描述

答案1

如前所述,由您的片段组成的 MWE(最小工作示例)不会重现您的问题。因此,以下仅是一些题外话:

  • 图形标签只有当图形包含标题时才有意义,标题必须在标签之前
  • 在序言中定义使用的版本pgfplots,请参阅下面的 MWE
  • 不会nodes near coords与相邻的条形图重叠,您应该减小使用的字体大小(至\scriptsize)并增加条形图之间的距离(如下面 MWE 中所做的那样)或增加条形图宽度(例如至bar width=1.5em
  • 我会将标签放在图表内,例如图表的左上角
  • 请始终提供 MWE,这是一个小型的可编译文档,可重现您的问题并可按原样进行测试。MWE 的示例如下:

\documentclass[a4paper,fleqn,12pt]{cas-sc}
\usepackage[numbers]{natbib}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.statistics}
\pgfplotsset{compat=1.17}

\newgeometry{bindingoffset=0.2in,
             margin=1in,
             footskip=.25in}

\begin{document}
    \begin{figure}[htb]
    \centering
    \begin{tikzpicture}
\begin{axis}[
    width=11cm,
    ybar=5pt,
    enlargelimits=0.15,
    x tick label style={rotate=90, anchor=east},
    symbolic x coords={Karate(P), Karate(Rand), Dolphins(P),
                       Dolphins(Rand), Football(P), Football(Rand)},
    nodes near coords,
    nodes near coords style={font=\scriptsize},
    legend style={legend pos=north west,
                  legend columns=-1,
                  /tikz/every even column/.append style={column sep=2mm},
                 },
            ]

\addplot coordinates{
    (Karate(P),0.378)       (Karate(Rand),0.24) (Dolphins(P),0.51)
    (Dolphins(Rand),0.25)   (Football(P),0.566) (Football(Rand),0.23)
                    };
\addplot coordinates{
    (Karate(P),0.369)       (Karate(Rand),0.17) (Dolphins(P),0.47)
    (Dolphins(Rand),0.19)   (Football(P),0.511) (Football(Rand),0.19)};
\legend{$Q_{\max}$, $Q_{\mathrm{avg}}$}
 \end{axis}
    \end{tikzpicture}
\caption{My figure}
\label{FIG:8}
    \end{figure}
\end{document}

其生产成果为:

在此处输入图片描述

  • 如果高于 MWE 仍然产生灰色勾号标签,则可能的解决方案是定义x tick label style
    x tick label style={rotate=90, anchor=east, text=black},

相关内容