[pstricks] Shading the area between two \listplots
Alan Ristow
ristow at ece.gatech.edu
Wed May 25 15:28:23 CEST 2005
Herbert Voss wrote:
> Alan Ristow wrote:
>
>> I am plotting two curves using the psgraph environment and I would
>> like to shade the area between the curves. I feel certain that I have
>> done this before, but I cannot figure out how. At any rate, I have a
>> minimal example below that produces two graphs: One with the two lines
>> and no shading, and one with my (rotten) attempt to shade the area
>> between the lines.
>>
>> The problem appears to be that I cannot draw a closed path using
>> \listplot. I suppose that a workaround might be to draw the data from
>> two different files, plotting the second set of data in reverse order
>> from the first. However, I would prefer to avoid that, if possible. Is
>> this possible?
>
>
>
>> % Shade the area between lines
>> \begin{psgraph}[axesstyle=frame,ticklinestyle=dotted,xticksize=0 10,%
>> yticksize=0 10](0,0)(10,10){1.75in}{1.1in}%
>> \readdata{\data}{data.dat}%
>> \pscustom[fillstyle=solid,fillcolor=gray]{%
>> \listplot[plotNo=1,plotNoMax=2]{\data}%
>> \listplot[plotNo=2,plotNoMax=2]{\data}%
>> }%
>> \end{psgraph}
>> \end{document}
>
>
> % Shade the area between lines
> \begin{psgraph}[axesstyle=frame](0,0)(10,10){1.75in}{1.1in}%
> \readdata{\data}{data.dat}%
> \pscustom[fillstyle=solid,fillcolor=gray]{%
> \psline(0,0)(0,1) % dummy lines for filling
> \listplot[plotNo=2,plotNoMax=2]{\data}%
> \psline(10,1)(10,0)} % dummy lines for filling
> \pscustom[fillstyle=solid,fillcolor=white]{%
> \psline(0,0)(0,1) % dummy lines for filling
> \listplot[plotNo=1,plotNoMax=2]{\data}%
> \psline(10,1)(10,0)} % dummy lines for filling
> \psgrid[griddots=5,gridlabels=0pt,subgriddiv=0,gridcolor=gray]
> \end{psgraph}
Thanks, Herbert, that solution is very clever. However, there are two
things about it that I dislike:
1. The white shading covers part of the x-axis, making the line appear
very thin compared to the other lines in the axes frame. (I'm not sure
why, because when I use a gray fill in place of the white fill this does
not seem to happen.)
2. I have always disliked \psgrid in combination with psgraph because it
places the gridlines on top of the axes frame. If the color used for the
\psgrid differs from the color of the frame, then off-color gridlines
are printed on top of the frame in the final output. In the code you
provided above, for example, gray dots are visible on top of the black
axes frame.
I've tried a few other things based on your example, so far with no
luck. If you have any other ideas I'd love to hear them, but I'm on a
deadline so for the short-term I will probably just go ahead and split
my data into two files.
Thanks!
Alan
More information about the PSTricks
mailing list