
Das habe ich in Geogebra aufgezeichnet:
Dies ist der Code, den ich beim Exportieren einer Tikz-Datei aus Geogebra erhalte:
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
ymajorgrids=true,
xmajorgrids=true,
xmin=-4.370038701302235,
xmax=4.373881990999934,
ymin=-0.5693858009107018,
ymax=5.2038438869554735,
xtick={-4,-3,...,4},
ytick={0,1,...,5},]
\clip(-4.370038701302235,-0.5693858009107018) rectangle (4.373881990999934,5.2038438869554735);
\draw [line width=2pt] (-3,1)-- (3,1);
\draw [shift={(0,1)},line width=2pt] plot[domain=0:3.141592653589793,variable=\t]({1*3*cos(\t r)+0*3*sin(\t r)},{0*3*cos(\t r)+1*3*sin(\t r)});
\begin{scriptsize}
\draw [fill=ududff] (-3,1) circle (0.5pt);
\draw [fill=ududff] (3,1) circle (0.5pt);
\end{scriptsize}
\end{axis}
\end{tikzpicture}
Das ist, was ich bekomme, wenn ich es in mein Latex-Dokument einfüge:
Warum bekomme ich das? Wie kann ich es beheben? Ich habe es mehrmals versucht ...
Antwort1
Das einzige Problem ist, dass der Umschaltbefehl keine Einheit deklariert hat cm
(z. B. shift={(0cm,1cm)}
). Der folgende Code sollte funktionieren:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{xcolor}
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
ymajorgrids=true,
xmajorgrids=true,
xmin=-4.370038701302235,
xmax=4.373881990999934,
ymin=-0.5693858009107018,
ymax=5.2038438869554735,
xtick={-4,-3,...,4},
ytick={0,1,...,5},]
\clip(-4.370038701302235,-0.5693858009107018) rectangle (4.373881990999934,5.2038438869554735);
\draw [line width=2pt] (-3,1)-- (3,1);
% The shift command has changed
\draw [shift={(0cm,1cm)},line width=2pt] plot[domain=0:3.141592653589793,variable=\t]({1*3*cos(\t r)+0*3*sin(\t r)},{0*3*cos(\t r)+1*3*sin(\t r)});
\begin{scriptsize}
\draw [fill=ududff] (-3,1) circle (0.5pt);
\draw [fill=ududff] (3,1) circle (0.5pt);
\end{scriptsize}
\end{axis}
\end{tikzpicture}
\end{document}