Anonymous 1123
Sometimes, I have to present the points (x,y) so that 2x + 3y + 6>0 or x+1<0 and x+y>0 in the same system of coordinates. How can I do it?

![ScreenHunter 1052.png](/image?hash=1644b7d8356d81e2ee372743b6523045ba2dc82d7e4851c1a7cbd84a37ed72e7)
user 3.14159
This is basic version, I consider adding some pgfplots version later. It defines a pic that takes the coefficients a, b and c as arguments and has a few more keys to play with. It also has a very rudimentary key constraint, which can be used as e.g.

constraint={2x+3y+6>0},


which allows you to put in the constraint as an equation, but this key does not deal with any special cases as of now.

\documentclass[tikz,border=3mm]{standalone}
\usepackage[outline]{contour}
\contourlength{0.6pt}
\usetikzlibrary{patterns.meta}
\tikzset{bullet/.style={circle,fill,inner sep=1.2pt},
pics/linear constraint/.style={code={\tikzset{linear constraint/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/linear constraint/##1}}
\pgfmathsetmacro{\myalpha}{atan2(\pv{b},\pv{a})}
\pgfmathtruncatemacro{\itest}{(\pv{a}==0?0:1)}
\pgfmathtruncatemacro{\jtest}{(\pv{b}==0?0:1)}
\ifnum\numexpr\itest+\jtest=0
\typeout{No meaningful condition because both a and b are zero.}
\else
\pgfmathsetmacro\myc{\pv{c}/sqrt(\pv{a}*\pv{a}+\pv{b}*\pv{b})}
\ifnum\itest=0
\pgfmathsetmacro\amax{\pv{xmax}}
\pgfmathsetmacro\amin{\pv{xmin}}
\pgfmathsetmacro\ah{max(abs(\pv{ymin}),abs(\pv{ymax}))-\pv{c}}
\else
\ifnum\jtest=0
\pgfmathsetmacro\amax{\pv{ymax}}
\pgfmathsetmacro\amin{\pv{ymin}}
\pgfmathsetmacro\ah{max(abs(\pv{xmin}),abs(\pv{xmax}))-\pv{c}}
\else
\pgfmathsetmacro\amax{max(abs(\pv{ymax}/sin(\myalpha)),abs(\pv{xmax}/cos(\myalpha)))+abs(\pv{c})}
\pgfmathsetmacro\amin{-max(abs(\pv{ymin}/sin(\myalpha)),abs(\pv{xmin}/cos(\myalpha)))-abs(\pv{c})}
\pgfmathsetmacro\ah{(max(abs(\pv{xmin}/sin(\myalpha)),
abs(\pv{xmax}/sin(\myalpha)),abs(\pv{ymax}/cos(\myalpha)),abs(\pv{ymax}/cos(\myalpha))+abs(\pv{c})))}
\fi
\fi
\begin{scope}[local bounding box=-plot]
\clip (\pv{xmin},\pv{ymin}) rectangle (\pv{xmax},\pv{ymax});
\path[rotate=\myalpha+180,linear constraint/excluded]
(\myc,\amax) -- (\myc,\amin) -- (\ah,\amin) -- (\ah,\amax) -- cycle;
\draw[thick,rotate=\myalpha+180] (\myc,\amax) -- (\myc,\amin);
\ifnum\itest=1
\path (-1*\pv{c}/\pv{a},0) node[bullet]{};
\fi
\ifnum\jtest=1
\path (0,-1*\pv{c}/\pv{b}) node[bullet]{};
\fi
\end{scope}
\path (-plot.north)
node[above,linear constraint/annotation]{$\ifnum\itest=1 \pgfmathtruncatemacro{\ktest}{sign(\pv{a})*(abs(\pv{a})==1?1:2)+2} \ifcase\ktest \pgfmathparse{\pv{a}}\pgfmathprintnumber\pgfmathresult\,x \or -x \or \or x \or \pgfmathparse{\pv{a}}\pgfmathprintnumber\pgfmathresult\,x \fi \fi \ifnum\jtest=1\relax \pgfmathtruncatemacro{\ltest}{sign(\pv{b})*(abs(\pv{b})==1?1:2)+2} \ifcase\ltest \pgfmathparse{\pv{b}}\pgfmathprintnumber\pgfmathresult\,y \or -y \or \or \ifnum\itest=1 + \fi y \or \ifnum\itest=1 + \fi \pgfmathparse{\pv{b}}\pgfmathprintnumber\pgfmathresult\,y \fi \fi \pgfmathtruncatemacro{\ktest}{sign(\pv{c})+1} \ifcase\ktest \pgfmathparse{\pv{c}}\pgfmathprintnumber\pgfmathresult \or \or +\pgfmathparse{\pv{c}}\pgfmathprintnumber\pgfmathresult \fi >0$};
\fi
\draw[-stealth] (\pv{xmin},0) -- (\pv{xmax},0)
node[below left]{\contour{white}{$x$}};
\draw[-stealth] (0,\pv{ymin}) -- (0,\pv{ymax})
node[below left]{\contour{white}{$y$}};
}},linear constraint/.cd,a/.initial=1,b/.initial=0,c/.initial=0,
xmin/.initial=-4,xmax/.initial=4,ymin/.initial=-4,ymax/.initial=4,
excluded/.style={pattern={Lines[angle=\myalpha+45]}},
annotation/.style={},
constraint/.code args={#1x#2y#3>0}{\tikzset{linear constraint/.cd,
a=#1,b=#2,c=#3}}}
\begin{document}

\begin{tikzpicture}
\path pic{linear constraint={a=2,b=3,c=6,
excluded/.append style={pattern color=red},
annotation/.append style={yshift=1.5em,red}}};
\end{tikzpicture}

\begin{tikzpicture}
\path pic{linear constraint={constraint={2x+3y+6>0},
excluded/.append style={pattern color=red},
annotation/.append style={yshift=1.5em,red}}};
\end{tikzpicture}

\begin{tikzpicture}
\path pic{linear constraint={a=-1,b=0,c=-1,
excluded/.append style={pattern color=red},
annotation/.append style={yshift=1.5em,red}}}
pic{linear constraint={a=1,b=1,c=0,
excluded/.append style={pattern color=blue},
annotation/.append style={blue}}};
\end{tikzpicture}
\end{document}

![ani.gif](/image?hash=52c117ba7fe4ee46706d6ca9e277bea1ef00df7bef084d254cae99af39afeb83)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.