4

I'm trying to figure out how to shade the area bound by 2 lines on a graph, and one of the axes on an x-y plot (technically, the area bound by 2 nullclines on a phase-plane plot). I've mucked about with pspicture, and made several attempts using psclip (based on a guess, and some online examples of shading between functions with >1 intersection point), but without much success. In the following (rather poor) MWE, I've left the axis ticks and labels, to help ordinate. Basiclly, I want to shade (in some color) in the upper=left area bound by the two lines. [If it matters, the two lines intersect at (1.94,2.44).]

Ultimately, I'm looking to generate something looking more or less like this:

enter image description here

Many thanks in advance to points on how to accomplish with pspicture (although I'm open to alternatives -- say, using tikz).

\documentclass{article}

\usepackage{pstricks-add}

\begin{document}

\begin{pspicture}(-3.5,-0.5)(4,7)
\begin{psclip}{
\pscustom[linestyle=none,algebraic,plotpoints=2000]{
\psplot[algebraic,plotpoints=20,yMaxValue=5.6%,linecolor=cyan
]{0}{2}{x*(-5.5/3.5)+5.5}%
 \psplot[algebraic,plotpoints=20,yMaxValue=5.6%,linecolor=cyan
   ]{0}{2}{x*(-4/5)+4}
   }
  }%
     \psframe*[linecolor=cyan,fillstyle=solid](2,2.2)(4,5.5)
   \end{psclip}
 \psplot[algebraic,plotpoints=20,yMaxValue=5.6%,linecolor=cyan
  ]{0}{3.5}{x*(-1.57143)+5.5}
   \psplot[algebraic,plotpoints=20,yMaxValue=5.6%,linecolor=cyan
  ]{0}{5}{x*(-4/5)+4}
  \psaxes{->}(0,0)(0,0)(6,6.5)
 \uput[-90](5.9,-.1){$H$}
 \uput[-135](-.1,6.7){$P$}
 \end{pspicture} 

  \end{document}
  • Do you really want to plot the lines as curves, or can you consider plotting them as lines (given by two points)? – Bernard Jul 4 at 21:04
  • For flexibility (i.e., if/when the nullclines are nonlinear), as curves/functions. I understand that for straight lines, I only need 2 points (which clearly would be easier for this example). – Johnny Canuck Jul 4 at 21:31
3

Here is a simplified code. The \psframe command and the psclip environment are not necessary here if you reorganise the definition of \pscustom in the correct order. I also used the optional arguments of \psaxes to place the H and P labels.

\documentclass[svgnames]{article}

\usepackage{pstricks-add}

\begin{document}

\begin{pspicture}(-3.5,-0.5)(4,7)
\pscustom[linestyle =none, algebraic,plotpoints=2000, fillstyle=solid, fillcolor =WhiteSmoke!70!Lavender!]{
\psplot[algebraic,plotpoints=20,yMaxValue=5.6%,linecolor=cyan
]{0}{1.944}{x*(-5.5/3.5)+5.5}%
 \psplot[algebraic,plotpoints=20,yMaxValue=5.6%,linecolor=cyan
   ]{1.944}{0}{x*(-4/5)+4}
  }%
 \psaxes{->}(0,0)(0,0)(6,6.5)[$H$,-110][$P$,-160]
\psset{algebraic,plotpoints=20,yMaxValue=5.6,linecolor=cyan }
 \psplot{0}{3.5}{x*(-5.5/3.5)+5.5}
 \psplot{0}{5}{x*(-4/5)+4}
 \end{pspicture}

  \end{document} 

enter image description here

  • Wonderful -- thank you! – Johnny Canuck Jul 5 at 12:15
  • You're welcome. It's a pleasure to help! – Bernard Jul 5 at 12:22
3
\documentclass{article}
\usepackage{pst-eucl,pstricks-add}
\begin{document}

\def\F{x*(-5.5/3.5)+5.5} \def\G{x*(-4/5)+4}
\begin{pspicture}[algebraic](-3.5,-0.5)(4,7)
  \pstInterFF[PointName=none,PointSymbol=none]{\F}{\G}{0}{I}
  \pscustom[linestyle=none,algebraic,fillstyle=solid,fillcolor=blue!30]{%
    \psplot{0}{\psGetNodeCenter{I}I.x}{\F}%
    \psplot{\psGetNodeCenter{I}I.x}{0}{\G}
  }
  \psplot{0}{3.5}{\F}%
  \psplot{0}{5}{\G}
  \psaxes{->}(0,0)(0,0)(6,6.5)[$H$,-90][$P$,0]
 \end{pspicture} 

\end{document}

enter image description here

  • Thanks very much. I haven't looked at pst-eucl before, but even a quick glance at the summary description of the package suggests it might be a very elegant solution to these sorts of plots generally. – Johnny Canuck Jul 5 at 12:15

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.