2

This question already has an answer here:

I have produced the following code, for a graph I am making:

\usepackage{tikz}
\begin{document}

\begin{figure}[h]
\centering
\caption{AMD top 10 SBP peers (2016)}
\label{FigAMDtop10SBPpeers}
\begin{tikzpicture}
\begin{axis}[
    ymin=0, ymax=8,
    ylabel = Annual Search Fraction,
    yticklabel=\pgfkeys{/pgf/number format/.cd,fixed,precision=0,zerofill}\pgfmathprintnumber{\tick}\%,
    axis background/.style={fill=gray!5},
    symbolic x coords={Intel,HP,Nvidia,Broadcom,Texas Instruments,Google,Microsoft,IBM},
    xtick=data]
    \addplot[ybar,fill={rgb:red,0;green,47;blue,135}] coordinates {
        (Intel,6.1529271206690564)
        (HP,1.3888888888888888)
        (Nvidia,1.045400238948626)
        (Broadcom,0.9557945041816009)
        (Texas Instruments,0.9109916367980884)
        (Google,0.6869772998805257)
        (Microsoft,0.6571087216248507)
        (IBM,0.6421744324970132)

    };
\end{axis}
\end{tikzpicture}
\end{figure}


\end{document}

which looks like:

enter image description here

Clearly, the x-labels are not appropriate. I was wondering if there is a way to make the entire x label visible, without rotating the label (i don't like the layout)? For a firm like Texas Instruments, which has 2 words, maybe put the second word on the line below?

EDIT: The possible solution is not what I am looking for, since that merely shifts every other label downwards. This is not what I want; I want to keep the label positionings next to each other.

marked as duplicate by JPi, Stefan Pinnow, Raaja, Phelype Oleinik, Sebastiano May 2 at 19:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • It is not a duplicate, as I don't want every other label to be pushed downwards. – Philip May 2 at 13:26
  • You said maybe put the second word on the line below, not that that was a requirement. Regardless, please make your example compilable, thanks. – JPi May 2 at 13:29
  • So you want to keep the labels at the same spot and in the same orientation but still get rid of the overlap? The only degree of freedom left is scaling them but that is not a good idea (after all people should be able to read them). What exactly are you asking for? – schtandard May 2 at 13:33
  • apparently you like to store elephant into lady handbag ... with your restriction you not have many option: reduce font size, increase image width, use abbreviation (TI for Texas Instruments) ... or simply relax your restrictions :-) – Zarko May 2 at 13:34
  • Despite being pretty new to LaTeX, I was thinking of using a line break, like you can do in text? i.e. \\ with the label, but I have not been able to find any solutions to this. – Philip May 2 at 13:35
1

With code borrowed from Including math environment in tick labels from newcommand with tikz

\documentclass{article}

\usepackage[margin=1in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\pgfplotsset{xpiaxis/.style={% instead of command define style ...
        xtick={0,...,8},%
        xticklabels={Intel,HP,Nvidia,Broadcom,\parbox{1in}{\centering{}Texas\\Instruments}}
    }
}
\begin{document}
\begin{figure}[h]
\centering
\caption{AMD top 10 SBP peers (2016)}
\label{FigAMDtop10SBPpeers}
\begin{tikzpicture}
\begin{axis}[
    width=\textwidth,
    ymin=0, ymax=8,
    ylabel = Annual Search Fraction,
    yticklabel=\pgfkeys{/pgf/number format/.cd,fixed,precision=0,zerofill}\pgfmathprintnumber{\tick}\%,
    axis background/.style={fill=gray!5},
    xpiaxis]
    \addplot[ybar,fill={rgb:red,0;green,47;blue,135}] coordinates {
        (1,6.1529271206690564)
        (2,1.3888888888888888)
        (3,1.045400238948626)
        (4,0.9557945041816009)
        (5,0.9109916367980884)
        (6,0.6869772998805257)
        (7,0.6571087216248507)
        (8,0.6421744324970132)

    };
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}

Not the answer you're looking for? Browse other questions tagged or ask your own question.