[R] Mapping 2D to 3D
H
@gent@ @end|ng |rom medd@t@|nc@com
Sat Sep 19 03:34:43 CEST 2020
On 09/18/2020 02:26 AM, Jeff Newmiller wrote:
> No, but fortunately you are off in the weeds. Density has an internally-computed "z" coordinate... you should be looking at ?geom_contour.
>
> On September 17, 2020 7:17:33 PM PDT, H <agents using meddatainc.com> wrote:
>> I am trying to understand how to map 2D to 3D using ggplot() and
>> eventually plot_gg(). I am, however, stuck on understanding how to
>> express the third variable to be mapped. This example:
>>
>> ggdiamonds = ggplot(diamonds, aes(x, depth)) +
>> stat_density_2d(aes(fill = stat(nlevel)),
>> geom = "polygon", n = 100, bins = 10,contour = TRUE) +
>> facet_wrap(clarity~.) +
>> scale_fill_viridis_c(option = "A")
>>
>> uses a variable nlevel that I now understand is calculated during the
>> building of the ggplot but I have not figured out from where it is
>> calculated or how to specify a variable of my choosing.
>>
>> Does anyone have a good reference for understanding how to specify this
>> variable? Most examples on the 'net seem to use the same dataset but do
>> not specify this particular aspect...
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
But looking at the code in my message above, how does one know what stat(nlevel) refers to? What if I wanted to map another variable in this particular dataset??
More information about the R-help
mailing list