Graphics, Figures & Tablesshading in pstricks

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

shading in pstricks

Post by Mini »

Hi,

I currently have something like this and I would like to shade the part inside the parabola but make the border the bottom part of the ellipse. I've tried pscustom but I can't seem to do it :(

Could anyone please help?

Thanks heaps

Code: Select all

\documentclass[12pt, fleqn, leqno]{article}
\pagestyle{empty}
\linespread{1.5}
\usepackage{polynom}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage[lmargin=1cm, rmargin=1cm, tmargin=1cm, bmargin=1cm]{geometry}
\newcommand{\cosec}{\operatorname{cosec}}

\begin{document}

\begin{figure}[!htb]
    \begin{center}
        \begin{pspicture}(-5,-1)(5,5)
          \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-5,-1)(5,5)[$x$,-90][$y$,180]
          \parabola{<->}(2.5,4)(0,0)
          \psellipse[linestyle=dashed](0,3)(2.15,0.5)
          \psline[linewidth=1.2pt, linecolor=white](0,2.53)(0,2.989)
          \psline[linestyle=dotted](-2,3)(2,3)
          \rput(-0.2,3){$h$}
        \end{pspicture}
    \end{center}
\end{figure}

\end{document} 

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

shading in pstricks

Post by CrazyHorse »

Mini wrote: I currently have something like this and I would like to shade the part inside the parabola but make the border the bottom part of the ellipse. I've tried pscustom but I can't seem to do it :(

Code: Select all

\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{pst-plot}

\begin{document}

\begin{pspicture}(-5,-1)(5,5)
 \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-5,-1)(5,5)[$x$,-90][$y$,180]
 \pscustom[fillstyle=solid,fillcolor=red!30]{%
   \parabola(2.15,3)(0,0)
   \psellipticarc(0,3)(2.15,0.5){180}{0}
 }
 \parabola{<->}(2.5,4)(0,0)
 \psellipse[linestyle=dashed](0,3)(2.15,0.5)
 \psline[linewidth=1.2pt, linecolor=white](0,2.53)(0,2.989)
 \psline[linestyle=dotted](-2,3)(2,3)
 \rput(-0.2,3){$h$}
\end{pspicture}

\end{document} 
Herbert
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

shading in pstricks

Post by Mini »

Hi again,

Thanks for your help.

But I'm having trouble once again with shading areas. Could you please have a look at how I would do this one?

I want to shade the area between the axes, the curve and the line that I've drawn.

Thanks again

Code: Select all

\documentclass[12pt, fleqn, leqno]{article}
\pagestyle{empty}
\linespread{1.5}
\usepackage{polynom}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage[lmargin=1cm, rmargin=1cm, tmargin=1cm, bmargin=1cm]{geometry}
\newcommand{\cosec}{\operatorname{cosec}}

\begin{document}
        \begin{pspicture}(-6,-5)(6,5)
          \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-6,-5)(6,5)[$x$,-90][$y$,180]
          \psline[linestyle=dashed](-6,3.14)(6,3.14)
          \psline[linestyle=dashed](-6,-3.14)(6,-3.14)
          \pscurve{<->}(-6,-2.5)(-5,-2.38)(-4,-2.21)(-3,-1.97)(-2,-1.57)(0,0)(2,1.57)(3,1.97)(4,2.21)(5,2.38)(6,2.5)
          \psline(2,0)(2,1.57)
        \end{pspicture}
    \end{center}
\end{figure}

\end{document} 
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

shading in pstricks

Post by CrazyHorse »

Mini wrote: But I'm having trouble once again with shading areas. Could you please have a look at how I would do this one?

I want to shade the area between the axes, the curve and the line that I've drawn.
please run your example by yourself before posting it here ...

Code: Select all

\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{pstricks}
\usepackage{pst-plot}

\begin{document}
\begin{pspicture}(-6,-5)(6,5)
  \pscustom[fillcolor=blue!20,fillstyle=solid,linestyle=none]{%
    \psecurve(-3,-1.97)(-2,-1.57)(0,0)(2,1.57)(3,1.97)
    \psline(2,1.57)(2,0)(0,0)
  }
  \psaxes[linewidth=1.2pt, labels=none, ticks=none]{->}(0,0)(-6,-5)(6,5)[$x$,-90][$y$,180]
  \psline[linestyle=dashed](-6,3.14)(6,3.14)
  \psline[linestyle=dashed](-6,-3.14)(6,-3.14)
  \pscurve{<->}(-6,-2.5)(-5,-2.38)(-4,-2.21)(-3,-1.97)(-2,-1.57)(0,0)(2,1.57)(3,1.97)(4,2.21)(5,2.38)(6,2.5)
  \psline(2,0)(2,1.57)
\end{pspicture}

\end{document} 
Herbert
Mini
Posts: 73
Joined: Thu Aug 06, 2009 12:46 pm

Re: shading in pstricks

Post by Mini »

Hi,

Thanks heaps for helping me out. I really do appreciate it and I think I'm getting the hang of this.

But in the code you've written, it also fills a little bit in the 3rd quadrant. Is this able to be fixed?

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

shading in pstricks

Post by CrazyHorse »

Mini wrote:But in the code you've written, it also fills a little bit in the 3rd quadrant. Is this able to be fixed?
delete the first pair of coordinates

Code: Select all

    \psecurve(-2,-1.57)(0,0)(2,1.57)(3,1.97)
Herbert
Post Reply