
Ich möchte wissen, wie man die Linien „kleiner als“ oder „größer als“ in einem Tikz-Diagramm zeichnet.
ich habe dieses schöne Diagramm gefunden, kann aber die „Zebralinien“ nicht zeichnen. Gibt es dafür ein Paket?
Für meine Diagramme verwende ich derzeit pgfplot
\documentclass[12pt, a4]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}[
axis x line=center,
axis y line=center,
xlabel=$x_1$,
ylabel=$x_2$,
xmin=-1,
ymin=-1,
xmax=8,
ymax=15,
xtick={-1,0,1,2,...,8},
ytick={0,2,3,4,6,8,10,12}
]
\addplot[mark=none, domain=-1:8] {-4*x + 8}; % -4x_1 -x_2 <= -8
\addplot[mark=none, domain=-1:8] {x + 3};
\addplot[mark=none, domain=-1:8] {2};
\addplot[mark=none, domain=-1:8] {-2*x + 12};
\addplot[fill=blue!20,draw=blue]coordinates{(1,4)(3,6)(5,2)(1.5,2)};
\draw[red, ->](3,6)--(3,9);
\node[label={180:{(3,6)}}, circle, fill=red, inner sep=2pt] at (axis cs:3,6) {};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
das wie folgt aussieht:
Antwort1
Ich beantworte meine eigene Frage dank des Kommentars von torbjørn
Dies kann durch Dekorationen erreicht werden.
Um verschiedene Farben für die Dekoration und die Linie selbst zu vereinfachen, habe ich diese beiden Hilfsmethoden erstellt
\newcommand{\lightgray}{black!30}
\newcommand{\addPlotLDown}[1]{
\addplot[mark=none, domain=-1:8, color=\lightgray,
decoration={border,segment length=1mm,amplitude=1.5mm,angle=-135},
postaction={decorate}
] {#1};
\addplot[mark=none, domain=-1:8] {#1};
}
\newcommand{\addPlotRUp}[1]{
\addplot[mark=none, domain=-1:8, color=\lightgray,
decoration={border,segment length=1mm,amplitude=1.5mm,angle=135},
postaction={decorate}
] {#1};
\addplot[mark=none, domain=-1:8] {#1};
}
Der Plot selbst kann dann mit diesen Anweisungen gezeichnet werden:
\begin{figure}[h]
\centering
\begin{tikzpicture}
\begin{axis}[
axis x line=center,
axis y line=center,
xlabel=$x_1$,
ylabel=$x_2$,
xmin=-1,
ymin=-1,
xmax=8,
ymax=15,
xtick={-1,0,1,2,...,8},
ytick={0,2,3,4,6,8,10,12}
]
\addplot[fill=blue!20,draw=none]coordinates{(1,4)(3,6)(5,2)(1.5,2)};
\addPlotRUp{-4*x + 8};
\addPlotLDown {x+3}
\addPlotRUp{2}
\addPlotLDown{-2*x+12}
\addplot[fill=none,draw=blue]coordinates{(1,4)(3,6)(5,2)(1.5,2)};
\draw[red, ->](3,6)--(3,9);
\node[label={180:{(3,6)}}, circle, fill=red, inner sep=2pt] at (axis cs:3,6) {};
\end{axis}
\end{tikzpicture}
\end{figure}