Graphics, Figures & TablesPSTricks | Absolute Value Inequality Shading

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

PSTricks | Absolute Value Inequality Shading

Post by coachbennett1981 »

Hello,

I am trying to shade the outside part of y>-2|x-3|+4, however with the following code, I can only shade inside. Can anyone tell me how to shade the outside?

Code: Select all

\documentclass[a4paper,ngerman,12pt,parskip]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathpazo}
\usepackage{babel}

\usepackage{pstricks-add}

\begin{document}

\begin{center}
\psframebox[fillstyle=solid,fillcolor=black!10,framesep=0pt]{%
\begin{pspicture*}(-3.2,-3.2)(6,6)
  \pscustom[fillstyle=solid,fillcolor=blue!20,linestyle=none,algebraic]{%
    \psplot{-3}{3}{2*x-2}
    \psplot{3}{7}{-2*x+10}
  }
  \psplot[linewidth=2pt,algebraic]{0}{7}{-2*abs(x-3)+4}
  \psaxes{<->}(0,0)(-3,-3)(5.8,5.8)[$x$,-90][$y$,0]
\end{pspicture*}}
\end{center}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTricks | Absolute Value Inequality Shading

Post by CrazyHorse »

coachbennett1981 wrote: I am trying to shade the outside part of y>-2|x-3|+4, however with the following code, I can only shade inside. Can anyone tell me how to shade the outside?
it is also possible to clip the area.

Code: Select all

\documentclass{scrartcl}
\usepackage{pstricks-add}

\begin{document}

\begin{center}
\psframebox[fillstyle=solid,fillcolor=black!10,framesep=0pt]{%
\begin{pspicture*}(-3.2,-3.2)(6.2,6.2)
  \pscustom[fillstyle=solid,fillcolor=blue!20,linestyle=none,algebraic]{%
    \psline(0,-2)(0,-3)(-3,-3)(-3,6)(6,6)(6,-2)
    \psplot{6}{3}{-2*x+10}
    \psplot{3}{-3}{2*x-2}
  }
  \psplot[linewidth=2pt,algebraic,plotpoints=100]{0}{6}{-2*abs(x-3)+4}
  \psaxes{<->}(0,0)(-3,-3)(5.8,5.8)[$x$,-90][$y$,0]
\end{pspicture*}}
\end{center}
\end{document}
Attachments
output
output
xx.png (3.13 KiB) Viewed 3310 times
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

PSTricks | Absolute Value Inequality Shading

Post by coachbennett1981 »

Thank you for the help. Can you explain the clipping part? This code line specifically.

Code: Select all

\psline(0,-2)(0,-3)(-3,-3)(-3,6)(6,6)(6,-2)
Edit:
I got it now. Thank you!
Post Reply