1

I'm graphing inequalities with tkz-euclide. I've figured out how to draw a dashed line on a coordinate grid, but I'm not sure how to shade it.

Here's what I have. How can I shade above or below the line?

\documentclass{article}
\usepackage{tkz-euclide} % coordinate plane
\begin{document}
  \begin{tikzpicture}[scale=0.40,transform shape]
    \tkzInit[xmax=6,ymax=6,xmin=-6,ymin=-6]
    \tkzGrid
    \tkzAxeXY
    \draw[ very thick,dashed,latex-latex] (-6,4) -- (6,0);
  \end{tikzpicture}
\end{document}

Dashed Line for Inequality

4

Since you are using TikZ commands already, you can do the shading with \fill. Here the opacity needs to be set to a low value, so the grid is still visible.

\documentclass{article}
\usepackage{tkz-euclide} % coordinate plane
\begin{document}
  \begin{tikzpicture}[scale=0.40,transform shape]
    \tkzInit[xmax=6,ymax=6,xmin=-6,ymin=-6]
    \tkzGrid
    \tkzAxeXY
    \draw[ very thick,dashed,latex-latex] (-6,4) -- (6,0);
    \fill[green,opacity=0.1] (-6,4) -- (6,0) -- (6,-6) -- (-6,-6) -- cycle;
    \fill[red,opacity=0.1] (-6,4) -- (6,0) -- (6,6) -- (-6,6) -- cycle;
  \end{tikzpicture}
\end{document}

enter image description here

3
  • Or, you can fill first and draw later (instead of changing opacity. – balcinus Oct 11 '17 at 6:42
  • @balcinus you could, but this would give you white rectangles around the numbers on the axis. – Mike Oct 11 '17 at 8:03
  • I see. I guess that's because of the tkz-euclide macros used in the given code. – balcinus Oct 11 '17 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.