1

I try to format a ybar diagram nicely.


Minimum Working Example (MWE):

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
    ybar                    = 1.5mm,
    ymin                    = 0,
    ymax                    = 300,
%   set layers              = true,
%   axis on top             = true,
    symbolic x coords       = {Blub, Blab, Blop},
    ymajorgrids             = true,
    nodes near coords,
    nodes near coords align = {vertical},
    nodes near coords style = {text=black},
    every node near coord/.append style={rotate=90, anchor=west},
    ]
    \addplot[fill=red, draw=red] coordinates {(Blab,180) (Blop,180) (Blub,180)};%
    \end{axis}
    \end{tikzpicture}
\end{document}

Screenshot of the result:

Screenshot of the result


Screenshot of the issue:

Screenshot of the issue 1


Description of the issue:

As you can see, the ybars are positioned in a visibility layer above the abscisse, therefore the abscisse is partly hidden by ybars. Well, I could easily activate set layers = true as well as axis on top = true, but in this case also the grid will be moved to the foreground layer while then hiding the node label texts. However, the node label texts should remain in the foreground above the grid lines (like seen here):

Screenshot of the issue 2

Therefore it is not possible to just activate the upper commands.

Is there an option available to only put abscisse (x-axis) and ordinate (y-axis) to the foreground layer of visibility while keeping the grids in the background?

The user marmot has posted an approach on how to keep the node text labels in the foreground, even when setting set layers = true and axis on top = true. Would it be possible to do something similar for abscisse and ordinate only while keeping grid in background?

Dave
  • 3,758
  • Into your code there is an error: Package pgfkeys Error: I do not know the key '/tikz/nodes near coords style', to which you passed 'text=black', and I am going to ignore it. Perhaps you misspelled it. [ \end{axis}] – Sebastiano Apr 07 '19 at 08:27
  • Thanks for your comment! In my case this MWE works completely fine? Hmm, now I am wondering... – Dave Apr 07 '19 at 08:55
  • @Sebastiano: I have updated my request. Now you can see it better I hope. :-) – Dave Apr 07 '19 at 09:15
  • 1
    Ah :-). I think I get it. You want it just above, right? That is, you want to see the x-axis and above it just a little bit you want to see the red bar. – Sebastiano Apr 07 '19 at 09:17
  • Haha. :-) I don't want to move/shift the x-axis or the plot actually. I just want to put the abscisse into a visibility layer above the plot, so the plot can not hide the x-axis anymore. :-) – Dave Apr 07 '19 at 09:20
  • 1
    @Sebastiano: I hope one can understand what I mean now. :-) I have just updated my request once again. :-) – Dave Apr 07 '19 at 09:23
  • I'm sorry I didn't help you. Many times I think I understand, but I don't. – Sebastiano Apr 07 '19 at 09:35
  • 1
    @Sebastiano: Ah, absolutely no worries! This is a great community - I really appreciate your help even for your approach to help! :-) – Dave Apr 07 '19 at 09:46
  • I'm doing what I can even though I'm with bronchitis right now. :-( +1 for all. – Sebastiano Apr 07 '19 at 09:50
  • Possibly duplicate: https://tex.stackexchange.com/a/288065/31034 –  Apr 07 '19 at 10:31
  • @ferahfeza: Indeed! Thanks a lot, now it is working! :-) – Dave Apr 07 '19 at 12:43
  • @Dave, your welcome. –  Apr 07 '19 at 12:46

0 Answers0