
como posso desenhar gráficos como este com tikz?
funções: f(x) = x^2 + 0,25, f(x) = x^2 + 0,1 e f(x) = x^2 + 0,4
todos eles com diagonal y=x.
Comecei com:
\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}
Mas não sei onde estou perdendo
Responder1
Você estava muito perto, faltam apenas algumas linhas. É fácil alterar a função para mostrar os outros dois gráficos.
\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}
Responder2
Se eu puder adicionar uma pequena cereja na resposta do @bmv, você pode se beneficiar ao declarar sua função assim
\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}