0

I did this little picture with GeoGebra:

enter image description here

As I want to use this picture in a Latex document GeoGebra gave me the following TikZ output:

\documentclass[10pt]{article}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm, scale = 2, transform shape]
\begin{axis}[
x=1.0cm,y=1.0cm,
axis lines=middle,
xmin=-0.1394822574065271,
xmax=1.630662854481368,
ymin=-0.1216534027299477,
ymax=1.5300196062900275,
xtick={0.0, 0.5, 1.0},
ytick={0.0, 0.5, 1.0},]
\clip(-0.9394822574065271,-0.1216534027299477) rectangle (1.630662854481368,1.5300196062900275);
\draw [line width=0.8pt] (0.,0.5)-- (0.5,1.);
\draw [line width=0.8pt] (0.5,1.)-- (1.,0.);
\draw (1.26,0.35) node[anchor=north west] {$x$};
\draw (0.05,1.54) node[anchor=north west] {$f(x)$};
\draw (0.69,0.73) node[anchor=north west] {$G_f$};
\end{axis}
\end{tikzpicture}
\end{document}

Unfortunately the proportions are absolutely horrible, as seen in this picture

enter image description here

I tried to fix it with scale but this did not get me close to what it should look like.

Has anyone an idea how the code can be improved?

3

I wouldn't use GeoCobra.

\documentclass[10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,xmax=1.3,xmin=-0.7,ymax=1.3,ymin=-0.1,
 xtick={-0.6,-0.4,...,0,0.2,0.4,...,1.2},ytick={0.2,0.4,...,1.2},xlabel=$x$,ylabel=$f(x)$]
  \addplot[samples at={0,0.5,1}] {ifthenelse(x<0.5,x+0.5,2-2*x)}
   node[pos=0.6,right] {$G_f$};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.