
У меня есть следующий код:
\RequirePackage{luatex85}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{bm}
\usepackage{tikz}
\usepackage{graphicx}
\pgfplotsset{every non boxed x axis/.append style={x axis line style=-}, every non boxed y axis/.append style={y axis line style=-}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=top,
axis y line=middle,
xmin=0, xmax=1.0,
ymin=0, ymax=1.0,
xtick={0, 0.2, 0.4, 0.6, 0.8, 1.0},
ytick={0, 0.2, 0.4, 0.6, 0.8, 1.0},
]
\end{axis}
\end{tikzpicture}
\end{document}
Ytick 1.0 не отображается (или его метка). Как это исправить?
решение1
Добавьте в преамбулу следующее:
\pgfplotsset{axis y line*/center/.code={%
\def\pgfplots@yaxislinesnum{1}%
\def\pgfplots@ytickposnum{2}%
\let\pgfplots@yticklabel@pos\pgfutil@empty
}}
Полный код:
\RequirePackage{luatex85}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{bm}
\usepackage{tikz}
\usepackage{graphicx}
\pgfplotsset{every non boxed x axis/.append style={x axis line style=-}, every non boxed y axis/.append style={y axis line style=-}}
\makeatletter
\pgfplotsset{
axis y line*/center/.code={\def\pgfplots@yaxislinesnum{1}\def\pgfplots@ytickposnum{2}\let\pgfplots@yticklabel@pos\pgfutil@empty},
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=top,
axis y line=middle,
xmin=0, xmax=1.0,
ymin=0, ymax=1.0,
xtick={0, 0.2, 0.4, 0.6, 0.8, 1.0},
ytick={0, 0.2, 0.4, 0.6, 0.8, 1.0},
]
\end{axis}
\end{tikzpicture}
\end{document}
решение2
axis y line=left
вместо axis y line=middle
?
\RequirePackage{luatex85}
\documentclass[tikz]{standalone}
\usepackage{pgfplots} % loads tikz, which loads graphicx
\usepackage{bm}
\pgfplotsset{every non boxed x axis/.append style={x axis line style=-}, every non boxed y axis/.append style={y axis line style=-}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=top,
axis y line=left,
xmin=0, xmax=1.0,
ymin=0, ymax=1.0,
xtick={0, 0.2, 0.4, 0.6, 0.8, 1.0},
ytick={0, 0.2, 0.4, 0.6, 0.8, 1.0},
]
\end{axis}
\end{tikzpicture}
\end{document}
решение3
Если вы закомментируете, axis y line=middle
то это сработает. Если вам нужно axis y line=middle
, попробуйте добавить небольшой дополнительный бит в диапазон y. Настройка ymax=1.0000001
будет работать.