You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
latex(ggv, height.panel=.41,
height.x.axis=.2, ## inch
width.y.axis=.3, ## inch
rowlabel="group",
vectorgraph.colname="Graph Panels")
does not complete. I traced it to my function
microplot.ggplot in file R/microplot.ggplot.R, lines 78 and 79
The underlying issue is that ggplot2_2.2.1 reports
Browse[1]> names(object$facet$params$cols)
NULL
and ggplot2_2.2.1.9000 reports
Browse[1]> names(object$facet$params$cols)
character(0)
I could just change my line 79 to look for either character(0) or NULL.
However, since there is a change in behavior in the results you are reporting, I will ask your advice
before making a change.
Thanks for your report. Would you mind providing a minimal reprex using only ggplot2 code? We don't know what's happening in lines 78 and 79 of your code.
Could you please rework your reproducible example to use the reprex package ? That makes it easier to see both the input and the output, formatted in such a way that I can easily re-run in a local session.
In my code, if there is no name for the column of panels in the graphics window, then I assign one.
The change in value for
names(ggv$facet$params$cols)
breaks my test for the existence of a name. Obviously I can test for the new value.
The issue is whether this change is intentional or an accidental byproduct.
Please let me know whether I should change my code.
rlang::quos()
#> named list()
names(rlang::quos())
#> character(0)
So going forward, you should expect the result of names(ggv$facet$params$cols) to be character(0).
More importantly, though, geom_point(shape=DF$rr.cc) is not valid ggplot2 code and things will break for you at some point if you use this construct, in particular if you're using it in faceted plots. You need to write geom_point(aes(shape=rr.cc)).
@rmheiberger Your code is simply not valid ggplot2 and is not guaranteed to work. See example below.
@hadley I feel this needs to be documented better. I see people making this mistake all the time, and usually all I can say is "don't do this" but I can't point to an article explaining why this is a problem. Can you think of a good place where this could go? Maybe a ggplot2 vignette? Or a blogpost somewhere?
Example for how things go wrong when you hand a data column to aes() or to a parameter:
library(ggplot2)
df<-data.frame(x=1:6,
y=1:6,
label= c("a", "b", "c", "a", "b", "c"),
colour= c("magenta", "green", "cyan", "magenta", "green", "cyan"))
# doesn't work, the indicated colors are not used, and colors also don't match within facets
ggplot(df, aes(x, y, colour=df$colour)) +
geom_point(size=3) +
facet_wrap(~label)
# this works in the sense that the indicated colors are used, but colors still don't match# within facets
ggplot(df, aes(x, y, colour=df$colour)) +
geom_point(size=3) +
facet_wrap(~label) +
scale_colour_identity()
# directly handing the colors to `geom_point()` also doesn't work
ggplot(df, aes(x, y)) +
geom_point(size=3, colour=df$colour) +
facet_wrap(~label)
# finally, if we map the colors via aes things work as expected
ggplot(df, aes(x, y, colour=colour)) +
geom_point(size=3) +
facet_wrap(~label) +
scale_colour_identity()
This example doesn't show how to produce in valid ggplot2 code what I have successfully
produced in both ggplot2_2.2.1.9000 and ggplot2_2.2.1. I specifically want the 12 characters c("1","2","3","4","5","6","7","8","9","A","B","C") as my plotting characters.
ggsh in my previous posting does exactly what I want. Please show me how to do that in valid ggplot2 syntax.
Activity
clauswilke commentedon May 26, 2018
Thanks for your report. Would you mind providing a minimal reprex using only ggplot2 code? We don't know what's happening in lines 78 and 79 of your code.
rmheiberger commentedon May 26, 2018
hadley commentedon May 28, 2018
Recreating @rmheiberger's email response with markdown to improve readability:
This is the relevant ggplot code from the demo
hadley commentedon May 28, 2018
Could you please rework your reproducible example to use the reprex package ? That makes it easier to see both the input and the output, formatted in such a way that I can easily re-run in a local session.
rmheiberger commentedon May 28, 2018
Totally simplified
In my code, if there is no name for the column of panels in the graphics window, then I assign one.
The change in value for
breaks my test for the existence of a name. Obviously I can test for the new value.
The issue is whether this change is intentional or an accidental byproduct.
Please let me know whether I should change my code.
clauswilke commentedon May 28, 2018
When rows or columns are not specified in
facet_grid()their names are now generated withquos(), which generates an empty named list:ggplot2/R/facet-grid-.r
Lines 189 to 190 in 5e9b688
So going forward, you should expect the result of
names(ggv$facet$params$cols)to becharacter(0).More importantly, though,
geom_point(shape=DF$rr.cc)is not valid ggplot2 code and things will break for you at some point if you use this construct, in particular if you're using it in faceted plots. You need to writegeom_point(aes(shape=rr.cc)).rmheiberger commentedon Jun 3, 2018
Thank you. I have changed the code to check on
character(0).Your suggestion about
geom_pointdoes not agree with?aes_linetype_size_shapewhich includes examples withoutaes(), for examplegeom_point(shape=5).ggshdoes what I want.ggaesgives an error.clauswilke commentedon Jun 3, 2018
@rmheiberger Your code is simply not valid ggplot2 and is not guaranteed to work. See example below.
@hadley I feel this needs to be documented better. I see people making this mistake all the time, and usually all I can say is "don't do this" but I can't point to an article explaining why this is a problem. Can you think of a good place where this could go? Maybe a ggplot2 vignette? Or a blogpost somewhere?
Example for how things go wrong when you hand a data column to
aes()or to a parameter:Created on 2018-06-03 by the reprex package (v0.2.0).
rmheiberger commentedon Jun 4, 2018
Thank you for writing back.
This example doesn't show how to produce in valid
ggplot2code what I have successfullyproduced in both
ggplot2_2.2.1.9000andggplot2_2.2.1. I specifically want the 12 charactersc("1","2","3","4","5","6","7","8","9","A","B","C")as my plotting characters.ggshin my previous posting does exactly what I want. Please show me how to do that in validggplot2syntax.clauswilke commentedon Jun 4, 2018
@rmheiberger I recommend you read up on how scales work, and then specifically
scale_shape_identity()andscale_shape_manual(). If you have further questions, please direct them to https://community.rstudio.com or https://stackoverflow.com/. The issue system is meant for bugs or feature requests.rmheiberger commentedon Jun 4, 2018
perfect. thank you.
this does what I want.
As far as I am concerned you may close this issue.
Rich
lock commentedon Dec 1, 2018
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/