如何改变条形图中节点和坐标的颜色

如何改变条形图中节点和坐标的颜色

需要改变条形图中的坐标和节点的颜色

\documentclass[12pt,a4paper]{report}
\usepackage[a4paper,bindingoffset=0.2in,%
            left=1 in,right=0.5in,top=1in,bottom=1in,%
            footskip=.25in]{geometry}
\usepackage{fontspec}
\usepackage[sfdefault,light]{roboto}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{tikz}
% Define bar chart colors
%
\definecolor{orange}{HTML}{FF8C00}
\pgfplotsset{width=6cm,compat=1.17}
\usetikzlibrary{backgrounds}
\usepackage{eso-pic,xcolor}
\usepackage{color} %include colors
\usepackage{xcolor}
\begin{document}
\flushleft
{\color{blue}
\Large{PV module fault Distribution}\\
}
\flushleft
\begin{tikzpicture}[background rectangle/.style={draw},
    show background rectangle][hbt!]
    \begin{axis}
    [axis line style={draw=none},
        title    ={\color{gray}High criticality factor faults - no. of modules affected},
        width  = 0.4*\textwidth,
        height = 5cm,
        major y tick style = transparent,
        xbar,
        bar width=14pt,
        xmajorgrids = true,
          nodes near coords,
          symbolic y coords={ table,module, module},
          xmin=0,  xmax=100,
        ytick = data,
        scaled x ticks = false,
    ]
        \addplot[style={orange,fill=orange,mark=none}]
            coordinates{(57,table) (63, module) (57, module)};
\end{axis}
\end{tikzpicture}
\end{document} 

我得到这样的: 在此处输入图片描述

我需要这样的: 在此处输入图片描述

答案1

使用nodes near coords style = graytick label style = gray

在此处输入图片描述

\documentclass[12pt,a4paper]{report}
\usepackage[a4paper,bindingoffset=0.2in,%
            left=1 in,right=0.5in,top=1in,bottom=1in,%
            footskip=.25in]{geometry}
\usepackage{fontspec}
\usepackage[sfdefault,light]{roboto}
\usepackage{pgfplotstable}% loads pgtplots,tikz,xcolor,graphicx,...
\pgfplotsset{width=6cm,compat=1.17}
\usetikzlibrary{backgrounds}

% Define bar chart colors
\definecolor{orange}{HTML}{FF8C00}

\usepackage{eso-pic}% not used in the example

\begin{document}
\begin{flushleft}
  \begin{tikzpicture}[background rectangle/.style={draw},
    show background rectangle]
    \begin{axis}
      [axis line style={draw=none},
        title ={High criticality factor faults - no. of modules affected},
        title style = gray,
        width = 0.4*\textwidth,
        height = 5cm,
        major y tick style = transparent,
        xbar,
        bar width=14pt,
        xmajorgrids = true,
        nodes near coords,
        nodes near coords style = gray,% <=== added
        tick label style = gray,% <=== added
        symbolic y coords={table,string,module},
        xmin=0,  xmax=100,
        ytick = data,
        scaled x ticks = false
      ]
      \addplot[style={orange,fill=orange,mark=none}]
          coordinates{(57,table) (63,string) (57,module)};
    \end{axis}
  \end{tikzpicture}
\end{flushleft}
\end{document}

相关内容