
Tenía un gráfico que recuerdo que funcionó bien en el pasado y de repente me di cuenta de que todo está escalado a un pequeño punto en la parte inferior del eje y. No estoy seguro de si algo cambió y no puedo encontrar el problema.
\begin{tikzpicture}
\begin{axis}[
axis lines = middle, %% instead of above two lines this one is enough
scaled ticks=false,
axis equal,
scale=0.5,
y=1cm,
x=3cm,
grid=none,
xmax=2.5,xmin=-0.01,
ymin=-1,ymax=5.2,
xlabel=$x$,ylabel=$y$,
xtick={0,0.5,1,1.5,2},
ytick={-1,0,1,2,3,4},
ylabel = $U(r)$,
xlabel = $r(r_M)$,
]
\draw[red, thick] (0, 5)--(0, 0)--(2.5, 0);
\draw[domain=0.84:2.5,smooth,variable=\x,blue, thick] plot ({\x},{0.1*\x^(-12)-0.1*\x^(-6)});
\end{axis}
\end{tikzpicture}
Respuesta1
Desde pgfplots
la versión 1.11 axis cs
es el sistema de coordenadas predeterminado. Pero debe configurarlo al menos 1.11
inmediatamente compat
después de cargar el paquete pgfplots
. Si no establece un valor, compat
se pre 1.3
utiliza.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}% comment this to see the issue
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle, %% instead of above two lines this one is enough
scaled ticks=false,
axis equal,
scale=0.5,
y=1cm,
x=3cm,
grid=none,
xmax=2.5,xmin=-0.01,
ymin=-1,ymax=5.2,
xlabel=$x$,ylabel=$y$,
xtick={0,0.5,1,1.5,2},
ytick={-1,0,1,2,3,4},
ylabel = $U(r)$,
xlabel = $r(r_M)$,
]
\draw[red, thick] (0, 5)--(0, 0)--(2.5, 0);
\draw[domain=0.84:2.5,smooth,variable=\x,blue, thick] plot ({\x},{0.1*\x^(-12)-0.1*\x^(-6)});
\end{axis}
\end{tikzpicture}
\end{document}
Pero yo usaría
\plot[domain=0.84:2.5,blue, thick] {0.1*x^(-12)-0.1*x^(-6)};
en lugar del segundo \draw
comando.