
Ich hatte ein Diagramm, das meiner Erinnerung nach früher einwandfrei funktionierte, und plötzlich fiel mir auf, dass alles auf einen winzigen Punkt am unteren Ende der Y-Achse skaliert ist. Ich bin mir nicht sicher, ob sich überhaupt etwas geändert hat, und kann das Problem nicht finden.
\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}
Antwort1
Seit pgfplots
Version 1.11 axis cs
ist das Standardkoordinatensystem . Sie müssen jedoch mindestens sofort nach dem Laden des Pakets einen Wert festlegen 1.11
. compat
Wenn pgfplots
Sie für keinen Wert festlegen, compat
wird pre 1.3
verwendet.
\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}
Aber ich würde verwenden
\plot[domain=0.84:2.5,blue, thick] {0.1*x^(-12)-0.1*x^(-6)};
stattdessen der zweite \draw
Befehl.