1

I am creating a histogram, which I've managed to do with the following code:

\begin{tikzpicture}
\centering
\begin{axis}[
    ymin=0, ymax=50,
    minor y tick num = 2,
    axis background/.style={fill=gray!5},
    area style,
    xticklabel=\pgfkeys{/pgf/number format/.cd,fixed,precision=1,zerofill}\pgfmathprintnumber{\tick}x,
    yticklabel=\pgfkeys{/pgf/number format/.cd,fixed,precision=0,zerofill}\pgfmathprintnumber{\tick}\%,
    xlabel={EV/EBIT},
    ylabel={Frequency}],
    ]
\addplot+ [ybar interval,mark=no, fill={rgb:red,0;green,47;blue,135},draw=gray!5] plot coordinates { (0, 0) (5, 7.6) (10, 40.1) (15, 30.5) (20, 10.7) (25, 4.1) (30, 2.4) (35, 1.4) (40, 1.0) (45, 0.7) (50, 0.4)};
\end{axis}
\end{tikzpicture}

which gives:

enter image description here

But what annoys my eyes, are the ticks on the bottom x-axis, top border and right border. Is there any way to change this?

2

To have the yticks only on the left, add ytick pos=left,, see section 4.15.2 Tick Alignment: Positions and Shifts of the pgfplots manual for more details. To remove the xticks altogether, just add xtick style={draw=none}.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xtick style={draw=none},ytick pos=left, 
    ymin=0, ymax=8000,
    minor y tick num = 2,
    axis background/.style={fill=gray!5},
    area style,
    ]
\addplot+ [ybar interval,mark=no, fill={rgb:red,0;green,47;blue,135},draw=gray!5] plot coordinates { (0, 32) (5, 1228) (10, 6658) (15, 5060) (20, 1786) (25, 684) (30, 404) (35, 228) (40, 165) (45, 119) (50, 72)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • Hi! The ticks were properly removed for the top and right, but not for the bottom. I looked in the manual and tried to implement: xtick pos=bottom, but that didn't solve the issue. – Philip Apr 19 '19 at 15:06
  • @Philip Yes, sorry, didn't read the question carefully enough. Fixed it (I hope). – user121799 Apr 19 '19 at 15:11
  • Thank you Marmot, that solved my issue! :) – Philip Apr 19 '19 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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