如何让这个条形图看起来更美观?

如何让这个条形图看起来更美观?

我对我的乳胶代码有三个疑问。 在此处输入图片描述 1. 如何让“我希望这一行位于最左侧,但编译后目前不在”这一行打印在最左侧?

  1. 我怎样才能使条形图与标签对齐?如果您编译我的代码,您应该会看到条形图conditional branches未与其标签对齐。

  2. 生成的条形图看起来相当原始。有人能帮我让它看起来更美观吗?

\documentclass[journal,onecolumn]{IEEEtran}

\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{float} % for \begin{figure}[H]
\usepackage{graphicx}

\usepackage[justification=centering]{caption}

% *** MATH PACKAGES ***

\usepackage{amsmath}
\usepackage{amssymb}


% IEEE Table
\usepackage{tabularx,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\setlength{\extrarowheight}{1pt}

\usepackage[tableposition=top]{caption}
\usepackage{siunitx}

% bar graph
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}


\begin{document}

\title{Computer Architecture}

\author{author}

\markboth{Computer Architecture}{}

% make the title area
\maketitle

% As a general rule, do not put math, special symbols or citations
% in the abstract or keywords.
\begin{abstract}
abstract
\end{abstract}

% Note that keywords are not normally used for peerreview papers.
\begin{IEEEkeywords}
IEEEkeywords
\end{IEEEkeywords}

\section{Introduction}

\IEEEPARstart{T}{his} report 


\section{Bar graphs}
I want this line to be on the left most side, but it is currently not after compilation.
\\
\centering
\begin{tikzpicture}
  \begin{axis}[
    title    = Percentage of Operation Types - FPPPP,
    xbar,
    y axis line style = { opacity = 0 },
    axis x line       = none,
    tickwidth         = 0pt,
    enlarge y limits  = 0.2,
    enlarge x limits  = 0.02,
    nodes near coords,
    symbolic y coords = {instructions with immediate operands, load instructions,
                         store instructions, floating-point instructions, direct jumps,
                         conditional branches}, 
  ]

  \addplot coordinates { (2,instructions with immediate operands) (43,load instructions)
           (18,store instructions) (47,floating-point instructions) (3,direct jumps) (6,conditional branches)};
  \end{axis}
\end{tikzpicture}
\end{document}

\section{Conclusion}
Conclusion



\end{document}

编辑:在我使用用户 ufo 提供的代码后,我得到了以下信息 在此处输入图片描述 如您所见,图表标题和其正下方的第一个条形之间有明显的间隙。有人可以将标题放在第一个条形的正上方吗?此外,我怎样才能使图表上的数字变成 6%、3% 等?使用类似的东西 (3\%,direct jumps) (6\%,conditional branches)不起作用。

答案1

对于问题 1:留下一个空行,而不是\\

对于问题 2:ytick=data

对于问题 3:请说出您想要更改的内容

\documentclass[journal,onecolumn]{IEEEtran}

\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{float} % for \begin{figure}[H]
\usepackage{graphicx}

%\usepackage[justification=centering]{caption}

% *** MATH PACKAGES ***

\usepackage{amsmath}
\usepackage{amssymb}


% IEEE Table
\usepackage{tabularx,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\setlength{\extrarowheight}{1pt}

%\usepackage[tableposition=top]{caption}
\usepackage{siunitx}

% bar graph
\usepackage[margin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}


\begin{document}

\title{Computer Architecture}

\author{author}

\markboth{Computer Architecture}{}

% make the title area
\maketitle

% As a general rule, do not put math, special symbols or citations
% in the abstract or keywords.
\begin{abstract}
abstract
\end{abstract}

% Note that keywords are not normally used for peerreview papers.
\begin{IEEEkeywords}
IEEEkeywords
\end{IEEEkeywords}

\section{Introduction}

\IEEEPARstart{T}{his} report 

normal text

\section{Bar graphs}
I want this line to be on the left most side, but it is currently not after compilation.

\centering
\begin{tikzpicture}
  \begin{axis}[
    title    = Percentage of Operation Types - FPPPP,
    xbar,
    y axis line style = { opacity = 0 },
    axis x line       = none,
    tickwidth         = 0pt,
    enlarge y limits  = 0.2,
    enlarge x limits  = 0.02,
    nodes near coords,
    ytick=data,
    symbolic y coords = {
        instructions with immediate operands, 
        load instructions,
      store instructions, 
      floating-point instructions, 
      direct jumps,
      conditional branches,
     }, 
  ]

  \addplot coordinates { (2,instructions with immediate operands) (43,load instructions)
           (18,store instructions) (47,floating-point instructions) (3,direct jumps) (6,conditional branches)};
  \end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容