[R-SIG-Mac] Failure using geom_polygon with 2D facet_grid: 1D works
John Helly
he||yj @end|ng |rom uc@d@edu
Mon Jun 13 01:04:52 CEST 2022
Aloha.
I'm trying to add a state map boundary to a 2D facet_grid in ggplot
which plots correlations against principal components (PC).
The 1D case works but I cannot discover what is causing the failure in
the 2D case. It may be a limit to facet_grid in some way or, more
likely, something I don't understand.
ggplot(A0G, aes(Longitude, Latitude, color=Correlation)) +
+ geom_point(size=2*abs(A0G$Correlation)) +
+ geom_polygon(data = ca_df, aes(x=Longitude, y=Latitude, fill = NA,
color = "black")) +
+ facet_grid(rows=vars(A0G$Lag), cols=vars(A0G$PC))
Error in `$<-.data.frame`(`*tmp*`, "PANEL", value = c(4L, 3L, 5L, 10L, :
replacement has 11112 rows, data has 516
The issue seems related to the dimensions of the map df and the data df
but I can't grok the problem since it works in the 1D case.
> dim(ca_df)
[1] 516 6
> dim(A0G)
[1] 11112 18
Any suggestions welcome. I'll just keep breaking the problem down if
there isn't anything obvious.
J.
--
John Helly, University of California, San Diego / San Diego Supercomputer Center / Scripps Institution of Oceanography / 760 840 8660 mobile /http://www.sdsc.edu/~hellyj
ORCID ID: orcid.org/0000-0002-3779-0603
[[alternative HTML version deleted]]
More information about the R-SIG-Mac
mailing list