4

I have three questions about my latex code. enter image description here 1. How can I make the line that says "I want this line to be on the leftmost side, but it is currently not after compilation." be printed at the leftmost side?

  1. How can I make the bar align with the label? If you compile my code, you should see that the bar of conditional branches is not aligned with its label.

  2. The generated bar graph looks quite primitive. Could someone help me make it look nicer?

\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}

EDIT: After I used the code provided by the user ufo, I got the following enter image description here As you see, there is an obvious gap between the graph title and the first bar that is right under it. Can someone make the title right above the first bar? In addition, how can I make the numbers on the graph be like 6%, 3%, etc? Using something like (3\%,direct jumps) (6\%,conditional branches) does not work.

1
  • you should explain what mean with "bar graph look more professional" ... now it looks just fine :-)
    – Zarko
    May 11, 2019 at 12:30

1 Answer 1

5

For problem 1: leave an empty line instead of \\

For problem 2: ytick=data

For problem 3: please say what you would like to change

\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}

enter image description here

1
  • @Zarko Could you move your comment to the question to make sure that the OP is notified about your comment?
    – ufo
    May 11, 2019 at 12:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .