4

enter image description here

For reasons, I need to move a tick label slightly to the right. Additionally I want to add an extra tick label at the zero of a function. However, the style chosen for the x label overwrites the style chosen for the extra tick label. Is this intended? I want the extra tick label to be directly below the tick

MWE( though I can't format it properly).

\documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots}\begin{document}\begin{tikzpicture}\begin{axis} [domain=0:1,
restrict y to domain= -1:1,
xmax=1.1, 
axis x line= middle, 
axis y line = left,
xtick={1},
x tick label style={anchor=north west},
xlabel =$s$, 
extra x ticks={0.25},    
every extra x tick/.style={ anchor=center},
extra x tick label={$s_c$},
no markers,]\addplot (x,x-0.25);\end{axis}\end{tikzpicture}\end{document}
4

every x tick style is admittedly a little confusing since it is meant to be a generic key to access extra ticks AND tick labels as if you are defining a new axis. I don't know if this is the official point of view but following can say more than I can summarize

\documentclass[border=5mm]{standalone} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain=0:1,
restrict y to domain= -1:1,
xmax=1.1, 
axis x line= middle, 
axis y line = left,
xtick={1},
x tick label style={anchor=north west},
xlabel =$s$, 
extra x ticks={0.25},
extra x tick label={$s_c$},
extra x tick style={grid=major,xticklabel style={anchor=north,red}},
no markers,
]\addplot (x,x-0.25);
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

|improve this answer|||||
  • +1 extra x tick style={grid=major,xticklabel style={anchor=north,red}} saved my day! I did not think that xticklabel style is necesarry and only used extra x tick style={}. – Dr. Manuel Kuehner Oct 2 '17 at 12:27

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.