Colorer une région du plan Crée par une droite
📅 May 06, 2024 | 👁️ Views: 20

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-5, xmax=5,
ymin=-5, ymax=5,
axis lines=middle,
xlabel={$x$},
ylabel={$y$},
xtick={-4,-2,...,4},
ytick={-4,-2,...,4},
grid=both,
]
% Define the function
\addplot[domain=-5:5.5, smooth, red, name path=curve] {(1 - x)/2};
% Find intersection with the top-most point on the left
\path[name path=laxis] (axis cs:-5,-5) -- (axis cs:-5,5); % axis x=-5
\path[name intersections={of=curve and laxis,by={A}}];
% Find intersection with the bottom-most point on the right
\path[name path=raxis] (axis cs:5,-5) -- (axis cs:5,5); % axis x=5
\path[name intersections={of=curve and raxis,by={B}}];
% Define the bottom-left corner of our domain
\coordinate (C) at (axis cs:-5,-5);
% Define the bottom-right corner of our domain
\coordinate (D) at (axis cs:5,-5);
% Fill the region below the curve
\fill[blue!20, opacity=0.6] (A) -- (B) -- (D) -- (C) -- cycle;
% Plot the points A, B, and C
\fill (A) circle (1pt) node[left] {A};
\fill (B) circle (1pt) node[right] {B};
\fill (C) circle (1pt) node[below left] {C};
\end{axis}
\end{tikzpicture}
\end{document}
Comme le régionnement du plan est facile à Créer en utilisant GeoGebra, je conseil de l'utiliser pour générer une figure comme cette figure
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-5, xmax=5,
ymin=-5, ymax=5,
axis lines=middle,
xlabel={$x$},
ylabel={$y$},
xtick={-4,-2,...,4},
ytick={-4,-2,...,4},
grid=both,
]
% Define the function
\addplot[domain=-5:5.5, smooth, red, name path=curve] {(1 - x)/2};
% Find intersection with the top-most point on the left
\path[name path=laxis] (axis cs:-5,-5) -- (axis cs:-5,5); % axis x=-5
\path[name intersections={of=curve and laxis,by={A}}];
% Find intersection with the bottom-most point on the right
\path[name path=raxis] (axis cs:5,-5) -- (axis cs:5,5); % axis x=5
\path[name intersections={of=curve and raxis,by={B}}];
% Define the bottom-left corner of our domain
\coordinate (C) at (axis cs:-5,-5);
% Define the bottom-right corner of our domain
\coordinate (D) at (axis cs:5,-5);
% Fill the region below the curve
\fill[blue!20, opacity=0.6] (A) -- (B) -- (D) -- (C) -- cycle;
% Plot the points A, B, and C
\fill (A) circle (1pt) node[left] {A};
\fill (B) circle (1pt) node[right] {B};
\fill (C) circle (1pt) node[below left] {C};
\end{axis}
\end{tikzpicture}
\end{document}
Related Courses, Exams, and Exercises
Course PDF:
📥 Download Colorer une région du plan Crée par une droite (PDF)