
wie kann ich mit Tikz solche Diagramme zeichnen?
Funktionen: f(x) = x^2 + 0,25, f(x) = x^2 + 0,1 und f(x) = x^2 + 0,4
alle mit der Diagonale y=x.
Ich habe angefangen mit:
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain = -.6:1,
samples = 50,
axis x line = center,
axis y line = center,
xlabel = {$x$},
ylabel = {$y$},
ticks = none
]
\addplot[blue] {x*x + 0.25};
\addplot[black] {x}
\end{axis}
\end{tikzpicture}
\end{document}
Aber ich weiß nicht, wo ich vermisse
Antwort1
Sie waren sehr nah dran, es fehlen nur noch ein paar Zeilen. Es ist einfach, die Funktion zu ändern, um die anderen beiden Diagramme anzuzeigen.
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain = -.6:1,
samples = 50,
axis x line = center,
axis y line = center,
xlabel = {$x$},
ylabel = {$y$},
try min ticks = 10,
scale only axis,
]
\addplot[blue] {x*x + 0.25};
\addplot[black] {x};
\end{axis}
\end{tikzpicture}
\end{document}
Antwort2
Wenn ich der Antwort von @bmv noch ein kleines Sahnehäubchen hinzufügen darf, könnte es für Sie von Vorteil sein, Ihre Funktion wie folgt zu deklarieren
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
% Declare the functions you need
\tikzset{
declare function={
f(\x)=\x*\x + 0.25;
g(\x)= f(\x) - 0.15;
h(\x)= f(\x) + 0.15;
}
}
\begin{axis}[
domain = -.6:1,
samples = 50,
axis x line = center,
axis y line = center,
xlabel = {$x$},
ylabel = {$y$},
try min ticks = 10,
scale only axis,
]
% easy to resuse
\addplot[blue] {f(x)};
% \addplot[red] {g(x)};
% \addplot[green] {h(x)};
\addplot[black] {x};
\end{axis}
\end{tikzpicture}
\end{document}