I would like to change some xticklabel styles but not all of them only few and not in specific positions (so it wont be 1st or last always). How could I change only lets say (3,5) labels to (Hello, World) and change their font size, make them bold and underline them?

enter image description here

\date{} % remove to get todays date
\maketitle % prints the info from \title, \author, \date

\pgfplotsset{enlarge y limits={value=0.15,upper}}
\pgfplotsset{xtick style={draw=none}}
    group style={
       group size=1 by 2,
       vertical sep=1.8cm
    ybar stacked,
    /pgf/bar width=1.66667cm,           
    legend style={at={(0.5,1.125)},
      anchor=north,legend columns=-1,font=\Large},
    symbolic x coords={1,2,3,4,5,6,7,8,9},
    enlarge x limits={abs=1.16667cm},  
    x tick label style={rotate=45,anchor=north east, inner sep=5pt},

\addplot+[fill=green,ybar,draw=black] plot coordinates {(1,5.07379)(2,5.94374)(3,6.18943)(4,7.70475)(5,20.8031)(6,2.14308)(7,8.02659)(8,1.30789)(9,31.2347)};
\addplot+[fill=brown,ybar,draw=black] plot coordinates {(1,2.66531)(2,0.87115)(3,1.52316)(4,0.350975)(5,0.299016)(6,0.216008)(7,4.20682)(8,0.237877)(9,1.20268)};
\legend{\strut action 1, \strut action 2}


EDIT after Zarko's comment enter image description here

So i tried to implement this red box around this very long text but it overprint itself on 3 and red square is only around that 3. How Could I fix it?

  • 1
    By use of extra x ticks={...} for which you define separate label style by extra x tick style={ ..., tick label style ={...}, ...}.
    – Zarko
    Commented Sep 13, 2020 at 19:58
  • Thank you man. I saw cool option that there is extra x tick style={tick label style={draw=red}} which draws red square around coord but if my extra x ticks={3}, and I change xticklabels={1,2,kind of long text,4,5,6,7,8,9}, my new text is printed on top of that number 3 and red square is around only 3. How can I fix it
    – etrusks
    Commented Sep 13, 2020 at 20:23
  • @Zarko I edited my question. Can you tell what im doing wrong?
    – etrusks
    Commented Sep 13, 2020 at 20:30
  • 1
    Where you use extra ticks you should not use ticks (there should be empty space). Sorry, but I'm currently busy with other obligation and can't prepare an answer now.
    – Zarko
    Commented Sep 13, 2020 at 20:42
  • @Zarko Thanks to you bro I figured it out. Thanks you very much man :)
    – etrusks
    Commented Sep 13, 2020 at 20:43

1 Answer 1


Thanks to Zarko I figured it out :) enter image description here

  1. Remove xticklabels you want to make special
  2. Add index to labels you want to make special
  3. Set those special labels
  4. Set those special label styles

Thanks Zarko!

  • 1
    I'm glad that you solve your problem yourself. +1!. You can accept own answer :-).
    – Zarko
    Commented Sep 13, 2020 at 22:43

You must log in to answer this question.

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