0

Is there a way to make the descriptions on this plot diagonal, so that they are readable?

enter image description here

The code I use:

% Data
%----------------------------------------
\pgfplotstableread[row sep=\\,col sep=&]{
    bench   & DCPT & RPT  \\
    twolf   & 0.99 & 1.00 \\
    bzip2s  & 1.00 & 1.00 \\
    swim    & 1.01 & 0.99 \\
    bzip2g  & 1.03 & 1.01 \\
    bzip2p  & 1.04 & 1.01 \\
    art110  & 1.06 & 1.02 \\
    art470  & 1.06 & 1.02 \\
    apsi    & 1.09 & 1.01 \\
    applu   & 1.09 & 1.03 \\
    galgel  & 1.10 & 1.02 \\
    wupwise & 1.25 & 1.08 \\
    ammp    & 1.68 & 1.12 \\
    }\mydata

% Plot
%----------------------------------------
\begin{figure}
\begin{tikzpicture}
    \begin{axis}[
            ybar,
            bar width=.1cm,
            width=\textwidth/2,
            %height=.5\textwidth/1,5,
            legend style={at={(0.5,1)},
                anchor=north,legend columns=-1},
            symbolic x coords={twolf, bzip2s, swim, bzip2g, bzip2p, art110, art470, apsi, applu, galgel, wupwise, ammp},
            xtick=data,
            ymin=.95,ymax=2,
            ylabel={Speedup},
        ]
        \addplot table[x=bench,y=DCPT]{\mydata};
        \addplot table[x=bench,y=RPT]{\mydata};
        %\addplot table[x=interval,y=carR]{\mydata};
        \legend{DCPT, RPT}
    \end{axis}
    \end{tikzpicture}
    \caption{Caption.}
    \label{fig:fig}
\end{figure}
1
  • 2
    Adding something like xticklabel style={rotate=60}, to the options of the axis might help. However, the bars are quote close to each other, so the symbolic ccordinates might still overlap.
    – leandriis
    Mar 25, 2020 at 16:43

2 Answers 2

1

Someone solved this for me, so I will share it. Adding this code xticklabel style={rotate=90} rotated the labels.

enter image description here

2
  • hm, as I see this "someone" was comment provided by @leandriis :-)
    – Zarko
    Mar 25, 2020 at 16:48
  • Actually it wasn't, but it was correct also!
    – C. K.
    Mar 25, 2020 at 21:55
1

Just for exercise, slightly modified your design and use for the symbolic coordinates data from table \mydata. Based on this answer:

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.16}

\pgfplotstableread[row sep=\\,col sep=&]{
    bench   & DCPT & RPT  \\
    twolf   & 0.99 & 1.00 \\
    bzip2s  & 1.00 & 1.00 \\
    swim    & 1.01 & 0.99 \\
    bzip2g  & 1.03 & 1.01 \\
    bzip2p  & 1.04 & 1.01 \\
    art110  & 1.06 & 1.02 \\
    art470  & 1.06 & 1.02 \\
    apsi    & 1.09 & 1.01 \\
    applu   & 1.09 & 1.03 \\
    galgel  & 1.10 & 1.02 \\
    wupwise & 1.25 & 1.08 \\
    ammp    & 1.68 & 1.12 \\
    }\mydata
\begin{document}
    \begin{tikzpicture}
\begin{axis}[x=10mm,
    ybar,
    bar width=3.2mm,
    enlarge x limits=0.1,
    enlarge y limits={.1, upper},
% y ticks style and label
ylabel={Speedup},
    ymin=0, 
% x axis ticks and style
    xtick=data,
    xticklabels from table={\mydata}{bench},    % <-------------------
    table/x expr = \coordindex,                 % <-------------------
    x tick label style = {rotate=45, anchor=east},
% legends and labels
    legend style = {legend columns=-1,
                    at={(0.5,0.98)},
                    anchor=north,
                    /tikz/every even column/.append style={column sep=1em}
                    },
    ]
\addplot [fill=blue!80!black]
            table [y=DCPT]  {\mydata};
            \addlegendentry{DCPT};
\addplot [fill=yellow!80!black]                       
            table [y=RPT]  {\mydata};
            \addlegendentry{RPT};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2
  • Thanks! Do you know if there's a way to have a plot with single columns, but change the color of only one of them?
    – C. K.
    Mar 25, 2020 at 22:17
  • 1
    @C.K. this is new question, It will be fer, that you as as such, that all member will see it and try to help.
    – Zarko
    Mar 25, 2020 at 22:41

You must log in to answer this question.

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