Message Boards Message Boards

[✓] Use the Filling Option to fill horizontally data values?

GROUPS:

As a Geotechnical Engineer, I frequently need to produce graphs showing all kinds of data plotted against depth (i.e. the data values are plotted along the horizontal x-axis and the corresponding depth values are plotted down the vertical y-axis). The Filling option is often useful in helping to visualise the data. However, as far as I can make out, the Filling option is only available for filling above, below or vertically between data values. I'd like to be able to also fill horizontally, either to the left, to the right or horizontally between data values. Thus far, the only way I've managed to achieve this is to use a fudge whereby I :

(1) plot the data values along the vertical y-axis and the corresponding depth values along the horizontal x-axis; then

(2) rotate the whole plot through 90 degrees.

Whilst this works, it's a bit of a nuisance. I'd be grateful to hear whether anyone out there is aware of a better way? And if not, I'd like to suggest to Wolfram that the Filling option be extended to include this functionality. I'm sure there must be many other applications where this would be useful.

All the best,

Ian

POSTED BY: Ian Williams
Answer
22 days ago

One way is to use graphic primitives:

Graphics[Polygon[
  Join[{{0, 0}}, 
   Table[{Cos[t], t}, {t, 0, 2 Pi, Pi/10}], {{0, 2 Pi}}]], 
 Axes -> True]
POSTED BY: Gianluca Gorni
Answer
22 days ago

Thanks, I can see how that would work as an alternative work around.

All the best,

Ian

POSTED BY: Ian Williams
Answer
22 days ago

Having tried it, Gianluca's suggestion of using a polygon works satisfactorily when plotting a single dataset. I had to combine the Polygon graphics primitive with the Line graphics primitive to join up the points with a line (drawing a line around the polygon doesn't produce the desired effect because it closes the polygon). However, like my rotation workaround, it's far from ideal. And it becomes increasingly messy to implement with the various options available in the ListPlot function when plotting multiple datasets. Which is a common requirement for me. I think an option to fill in the horizontal direction would be a good addition.

There also appears to be a bug in the ListPlot function. This occurs when the Epilog or Prolog options are used in conjunction with the ScalingFunctions option set to "Reverse" (another common requirement). In this case I've had to negate the y-values when they're used in the Prolog/Epilog section. My workaround this issue has been to introducing a scaling factor (either plus or minus 1). A simple example that illustrates the issue is attached. Would be good to know whether it's a real bug or a mistake on my part.

All the best,

Ian

Attachments:
POSTED BY: Ian Williams
Answer
22 days ago

Group Abstract Group Abstract