[R] the volcano orientation

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Sun May 10 23:03:23 CEST 2020


> Does anyone know why 'volcano' is oriented as it is?
> image(volcano)  ## filled.contour is the same

Great question!

graphics::image produces a "plot".
It follows the same x y conventions as other plots in the graphics package.
It's *defaults* are not designed to display photos, etc.

However, the format of the volcano data is not consistent with either
the defaults of graphics::image or what I (personally) would expect in
a photographic data, with top-left value at top-left of matrix and
bottom-right point at bottom-right of matrix, but that's debatable...

According, the documentation of the volcano data:

    A matrix with 87 rows and 61 columns,
    rows corresponding to grid lines running east to west
    and columns to grid lines running south to north.

Perhaps that could be improved slightly...?

And one more thing that caught me out.
My initial expectation (using a simple interpretation) was the data
would need to be transposed and then either the ylim reversed or the
rows reversed.
But when I tried to plot the volcano data using my own function (which
does just that), I got the wrong result.

But in the documentation for graphics::image we have:

    "Need to transpose and flip"
    image(t(volcano)[ncol(volcano):1,])

Which produces the right result.

I had to think about this for a while...

The example for graphics::image above is actually transposing the
matrix *twice*.
First in the input to the function, and then again (implicitly), where
rows (going down the data) are interpreted as x (going right across
the plot).



More information about the R-help mailing list