# pstricks: Color area under graph: what is dup?

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?

• dup means that the top stack entry is duplicated. See e.g. ugrad.math.ubc.ca/Flat/stack-ref.html#PSdup Nov 14, 2016 at 19:35
• E.g., (!3 dup log) evaluates to the coordinate (3,log(3)). Nov 14, 2016 at 19:43

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}


• Is it possible to color the area between two graphs? Nov 21, 2016 at 15:59
• – user2478
Nov 21, 2016 at 16:15