I want to hatch the area under a curve (graph of a function) with oblique lines on an interval (to illustrate the function's integral on that interval). This can be done elegantly in gnuplot...
...but I simply cannot reproduce this with pgfplots. The only solution I managed to find with google is the use of the patterns tikz library, however it is unacceptibly ugly:
I'm not aware of any way to alter the color, line width and - especially - the distance between the hatching lines when patterns library is employed. Is there any way to set it? (So that I can change it to resemble the gnuplot version.)
Or, should I choose a completely different approach to reproduce the gnuplot-style hatching...?
Also note that
- pgfplots changes the color of the x-axis to red on the interval (which is not a critical problem, of course, but not elegant).
- the legend for the filling is much more logical in case of gnuplot. Can I reproduce it with pgfplots?
Here is the code I currently use:
\begin{figure}[ht!]
\centering
\begin{tikzpicture}
\begin{axis}[xmin=-4,xmax=4,xlabel={z},ymin=0,ymax=1]
\addplot[color=red,domain=-4:4,samples=100] {1/sqrt(2*pi)*exp(-x^2/2)};
\addlegendentry{z}
\addplot[color=red,fill=red, pattern=north east lines, domain=0:1,samples=100] {1/sqrt(2*pi)*exp(-x^2/2)} \closedcycle;
\addlegendentry{Interval}
\end{axis}
\end{tikzpicture}
\end{figure}