\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}
\draw[thick, dotted] (0,0) -- (1,1);
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
\end{document}
Asked
Active
Viewed 58 times
2
Qrrbrbirlbel
- 119,821
Tigas
- 520
1 Answers
2
Always set compat level when using PGFPlots. Do not use explicit axis cs: - it is default since level 1.11. To not have completely empty axis, set xmin, xmax, ymin and ymax or add a plot.
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0, xmax=1, ymin=0, ymax=1]
\draw[thick, dotted] (0,0) -- (1,1);
\end{axis}
\end{tikzpicture}
\end{document}
hpekristiansen
- 37,006


[xmin=0, xmax=1, ymin=0, ymax=1]and use(axis cs:0,0) -- (axis cs:1,1)(for older versions of pgfplots) or\pgfplotsset{compat=1.13}. – dexteritas Oct 20 '22 at 09:44pgfplots, about both the compatibility level and the null axis range. Never blindly ignore warnings... they are there for something! – Rmano Oct 20 '22 at 10:18