2021-2022/tools/examples/tikzpicture.tex

64 lines
1.5 KiB
TeX
Raw Normal View History

\documentclass[a4paper,10pt]{article}
\RequirePackage[utf8x]{inputenc}
\RequirePackage[french]{babel}
\RequirePackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\usepgfplotslibrary{external}
\RequirePackage{tkz-tab}
\RequirePackage{tkz-fct}
\title{Snippets pour tikzpicture}
\date{}
\author{Benjamin Bertrand}
\begin{document}
\section{La base}
\begin{tikzpicture}
% par défaut les unités sont en cm
% un segment
\draw (0, 0) -- (1, 0);
% Coordonnées relatives
\draw (0, 0) -- ++(0, 1);
% Coordonnées polaire (angle: rayon)
\draw (0, 0) -- (45: 1);
% une figure pleine
\fill (2, 2) -- (1, 1) -- (2, 3) -- cycle;
% Un cercle (centre et rayon)
\draw (4, 1) circle (1);
% rectangle
\draw (5, 0) rectangle (6, 6);
\end{tikzpicture}
\section{Graphiques de fonctions}
\begin{tikzpicture}
\begin{axis}[
axis lines = center,
%grid = both,
xlabel = {$x$},
xtick distance=1,
ylabel = {$y$},
ytick distance=1,
legend pos = north west,
legend entries={$f(x)$, $g(x)$}
]
\addplot[domain=-6:7,samples=40, color=red, very thick]{-0.1*(x+5)*(x-1)*(x-6)};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[axis x line=bottom,axis y line = left]
\addplot[ybar,fill=blue,draw=blue,bar width=1cm] coordinates { (1,194) (2,213) (3,251)(4,233) (5,194)}; \end{axis}
\end{tikzpicture}
\end{document}