# TikZ/PGF \closedcycle to y axis

Consider the following MWE:

\documentclass{article}
\usepackage{tikz, pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
{(1.5*x - 4.5)^2/(10*x) + 1} \closedcycle ;
{(1.5*x - 4.5)^2/(10*x) + 1}
node[at start, above, black] {$(x1,y1)$}
node[at end, above, black]   {$(x2,y2)$};
\end{axis}
\end{tikzpicture}
\end{document}


which produce this

What I want is to

1. Fill the area between the blue curve and the x-axis (red fill)
2. Fill the area between the blue curve and the y-axis, that is, indicating the region interval y2 to y1 on the y-axis.

I was hoping there is some way to specify \closedcycle with respect to the y-axis or similar.

A solution could of course be to calculate the points (x1,y1) and (x2,y2), but it feels very un-TikZy.

(This means that there will be a white rectangle defined by the origin, (x1,0), (x1,y2) and (0,y2))

-
You can draw a second function. – Marco Daniel May 11 '13 at 13:51
Could you please elaborate? – Holene May 11 '13 at 13:52
Would this be OK : {(1.5*x - 4.5)^2/(10*x) + 1} |- (axis description cs:0,0) |- (current plot begin) ; instead of \closedcycle ? – percusse May 11 '13 at 13:54
I mean \addplot [domain=0:0.7,samples=2, fill=red!20] {(1.5*0.7 - 4.5)^2/(10*0.7) + 1} \closedcycle ; – Marco Daniel May 11 '13 at 13:55
Neither works. I'll update the question in a bit. – Holene May 11 '13 at 14:32

You can define a new command \closedcycley that does the same as the normal \closedcycle, but for the y axis. If you then plot the function twice, once with \closedcycle and once with \closedcycley, both times slightly transparently, you'll get the following:

\documentclass[border=5mm]{standalone}
\usepackage{tikz, pgfplots}

\makeatletter
\def\closedcycley{%
-| (perpendicular cs:
horizontal line through={(current plot begin)},
vertical line through={(\pgfplots@ZERO@x,\pgfplots@ZERO@y)})
-- cycle
}%
\makeatother

\begin{document}
\begin{tikzpicture}
\begin{axis}[axis on top]
node[at start, above, black] {$(x1,y1)$}
node[at end, above, black]   {$(x2,y2)$};