1

For coloring an area under a graph, there exist multiple approaches with pstricks.

I found a solution that was never mentioned on stack-exchange, but seems to be really simple:

\psplot[linewidth=1pt,linecolor=blue]{0.01}{5}{x log}
\pscustom[fillstyle=solid,fillcolor=cyan,linestyle=none]{%
  \psline(3,0)(!3 dup log)
  \psplot{3}{4}{x log}
  \psline(!4 dup log)(4,0)}
\psaxes{->}(0,0)(-.5,-2)(5,1)

However, I do not know how to adapt this example to e.g. x^2 because I do not understand what dup does. Can anybody explain it?

2

1 Answer 1

1

You can use the algebraic notation instead:

\documentclass{article}
\usepackage{pst-plot}
\begin{document}

\begin{pspicture}(-1,-2)(6,2)
\psplot[linewidth=1pt,linecolor=blue,algebraic]{0.01}{5}{log(x)}
\pscustom[fillstyle=solid,fillcolor=cyan,linestyle=none]{%
    \psline(3,0)(*3 {log(3)})
    \psplot[algebraic]{3}{4}{log(x)}
    \psline(*4 {log(4)})(4,0)}
\psaxes{->}(0,0)(-.5,-2)(5,1)   
\end{pspicture} 

\end{document}

enter image description here

2

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.