条形图的问题 - 颜色、不全部显示、格式数字

条形图的问题 - 颜色、不全部显示、格式数字

我正在尝试制作条形图但遇到一些问题:

  • 我希望颜色是白色和黑色!10
  • 第一个条形图没有出现,已经尝试更改代码,但没有改变
  • 我希望数字显示如下 7 084 449€

    \documentclass[oneside,12pt]{scrbook} %scrbook has more options than article
    \usepackage[autocite=inline, labeldate=true, uniquename=full,uniquelist=true, style=authoryear,backend=bibtex]{biblatex} 
    \usepackage{lipsum} %easy acess to the text
    \usepackage{scrhack} %patches other packages to make them work better
    
    \usepackage{amsmath}
    \usepackage[standard]{ntheorem}
    \usepackage[algo2e]{algorithm2e}
    
    \usepackage{tikz}%esquema
    \usetikzlibrary{arrows}%esquema
    
    % set up document fonts
    \usepackage[T1]{fontenc}
    \usepackage{lmodern,textcomp}
    
    
    \usepackage{setspace} %espaço titulo e texto
    \usepackage{enumitem} %control layout of itemize, enumerate, description
    \usepackage{scrpage2} %control of page headers and footers
    \usepackage{listings}
    \usepackage{indentfirst} %primeira frase começar mais à frente
    
    \usepackage{chngcntr}
    \counterwithout{figure}{chapter}
    \counterwithout{table}{chapter}
    
    \usepackage{multirow}
    
    \usepackage{calc}
    \usepackage{ifthen}
    \usepackage{tikz}
    
    
    \usepackage{pgf-pie}
    \usepackage{pgfplots}
    \usepackage{bchart}
    
    \usepackage{tikz,stackengine}
    \def\stackalignment{r}
    \setstackgap{S}{2pt}
    \begin{document}
    
    \begin{center}
    \begin{tikzpicture}
    \begin{axis}[
    xbar,
    y axis line style = { opacity = 0 },
    axis x line       = none,
    tickwidth         = 0pt,
    enlarge y limits  = 0.09,
    enlarge x limits  = 0.05,
    symbolic y coords = {Concentration, Currency, Spread, Property, Equity, Interest rate},
    nodes near coords,
    ]
    \addplot coordinates { (0\texteuro,Concentration) (0\texteuro,Currency)
                     (6 243 104\texteuro,Spread)  (10 963 023 \texteuro,Property) (34 222 001\texteuro,Equity) (8 084 449\texteuro,Interest rate)};
    \addplot coordinates { (30 513 517\texteuro,Concentration) (1 343     466\texteuro,Currency)
                     (6 243 104\texteuro,Spread)  (19 963 023\texteuro,Property) (14 222 001\texteuro,Equity) (7 084 449\text euro,Interest rate) };
    \legend{Changed allocation, Initial value}
    \end{axis}
    \end{tikzpicture}
         \captionof{figure}{Solvency capital requirements for the market risk of the initial portfolio}
          \end{center}
    
    \end{document}
    

您能提供一些帮助吗?:)

答案1

也许你正在寻找类似的东西

在此处输入图片描述

代码:

\documentclass[oneside,12pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern,textcomp}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\begin{document}

\begin{center}
  \begin{minipage}{\linewidth}
    \centering
    \begin{tikzpicture}
      \begin{axis}[
          xbar,
          y axis line style = {draw=none},
          axis x line       = none,
          tickwidth         = 0pt,
          enlarge y limits  = {abs=12pt},
          enlarge x limits  = 0.05,
          symbolic y coords = {Concentration, Currency, Spread, Property, Equity, Interest rate},
          ytick=data,
          nodes near coords={\pgfmathprintnumber[fixed,set thousands separator={\,}]{\pgfplotspointmeta}\,\texteuro},
          legend style={anchor=south},
          reverse legend
      ]
        \addplot[fill=white] coordinates { 
          (0,Concentration)
          (0,Currency)
          (6 243 104,Spread)
          (10 963 023,Property)
          (34 222 001,Equity)
          (8 084 449,Interest rate)
        };
        \addplot[fill=black!10]coordinates {
          (30 513 517,Concentration)
          (1 343     466,Currency)
          (6 243 104,Spread)
          (19 963 023,Property)
          (14 222 001,Equity)
          (7 084 449,Interest rate)
        };
        \legend{Changed allocation, Initial value}
      \end{axis}
    \end{tikzpicture}
    \captionof{figure}{Solvency capital requirements for the market risk of the initial portfolio}
  \end{minipage}
\end{center}
\end{document}

相关内容