TeX - LaTeX Asked by warship on October 29, 2020
How do I use extra y tick
(or some suitable alternative) to create a second labeled y-axis with the exact same tick mark positioning as the first labeled y-axis, but instead of the numbers 0, 0.2, 0.4, 0.6, 0.8, 1
, use A, B, C, D, E
? I have already placed the second y-axis tick mark positions with ytick pos=both.
documentclass{article}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}
begin{axis}[ytick pos=both]
addplot {rnd};
end{axis}
end{tikzpicture}
end{document}
You can use another axis
environment.
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.12}
begin{document}
begin{tikzpicture}
begin{axis}[axis y line*=left,ymin=-0.1,ymax=1.1]
addplot {rnd};
end{axis}
begin{axis}[hide x axis,axis y line*=right,ymin=-0.1,ymax=1.1,
ytick=empty,
extra y ticks={0,0.2,...,1},
extra y tick labels={A,B,...,F}
]
addplot[draw=none] {x}; % dummy plot
end{axis}
end{tikzpicture}
end{document}
Use same values for ymin
and ymax
for both the axis and make use of extra yticks
and extra y tick labels
to customise the entries.
Correct answer by user11232 on October 29, 2020
documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=1.12}
begin{document}
begin{tikzpicture}
begin{axis}[axis y line*=left,ymin=-0.1,ymax=1.1]
addplot {rnd};
end{axis}
begin{axis}[hide x axis,axis y line*=right,ymin=-0.1,ymax=1.1,
ytick=empty,
extra y ticks={0,0.2,...,1},
extra y tick labels={A,B,...,F}
]
addplot[draw=none] {x}; % dummy plot
end{axis}
end{tikzpicture}
end{document}
Answered by Nob Som on October 29, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP