lets-plot
lets-plot copied to clipboard
geom_point cannot be plot when the input for the parameter 'shape' is a string
Preconditions Plot the following:
extra_points = pd.DataFrame({'a': [0, 0], 'b': [1, 4]})
plot = ggplot() + geom_point(data=extra_points, mapping=aes(x='a', y='b'), shape='X')
The following would be shown:
In R, you would have the following
library(ggplot2)
extra_points <- data.frame(x = c(3.0, 4.0, 5.0), y= c(3.0, 4.0, 5.0))
# create factors with value labels
mtcars$gear <- factor(mtcars$gear)
mtcars$am <- factor(mtcars$am)
mtcars$cyl <- factor(mtcars$cyl)
ggplot() +
geom_point(data = mtcars, aes(x = wt, y = drat, color = gear, shape = am)) + geom_point(data = extra_points, aes(x, y), shape = 'X', size = 10)
You can find more about this here:
http://sape.inf.usi.ch/quick-reference/ggplot2/shape