Water density profile

I know the first one is a rdf profile and it was plotted by gmx rdf command, but how can I plot water density graph?
gr r

You can use gmx density to obtain the density of a given species along the length of the box, but that would have to be subsequently transformed into relative distance from the micelle rather than the absolute position along the box.

Thank you