Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

geom_point borders in ggplot2 2.0.0

Tags:

r

ggplot2

In the most recent verion of ggplot2, a change appears to have been made in the way that geom_point is rendered.

For instance, if I attempt to do alpha shading, then I get the following appearance:

library(ggplot2)

ggplot(mtcars) +
  geom_point(aes(wt, qsec),
            size  = 8,
            stroke = 0,
            alpha = .3)

enter image description here

How can I get ggplot to mimic its earlier behavior, and have the points appear without any border?

Edit:

As I said, this is occurring in:

the most recent version of ggplot2

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_2.0.0

loaded via a namespace (and not attached):
[1] labeling_0.3     colorspace_1.2-6 scales_0.3.0     plyr_1.8.3       tools_3.2.3      gtable_0.1.2     Rcpp_0.12.2      grid_3.2.3       munsell_0.4.2   

Edit 2:

These borders also occur in the github version: ggplot2_2.0.0.9000

like image 388
tomw Avatar asked Dec 21 '15 14:12

tomw


People also ask

What does geom_point () do when used with Ggplot ()?

The function geom_point() adds a layer of points to your plot, which creates a scatterplot. ggplot2 comes with many geom functions that each add a different type of layer to a plot.

How do I change border thickness in R?

Now to change the thickness of border, we simply use a parameter inside geom_point() function called stroke, which specify the thickness of the border of points in Scatterplot.

How do I change the shape of a point in ggplot2?

Change point shapes, colors and sizes manually : The functions below can be used : scale_shape_manual() : to change point shapes. scale_color_manual() : to change point colors. scale_size_manual() : to change the size of points.

How do I add a data point in ggplot2?

To add an extra point to scatterplot using ggplot2, we can still use geom_point function. We just need to use aes function for quoting with new values for the variables, also we can change the color of this point using colour argument.


1 Answers

In an email to the ggplot2 listserve, Hadley mentions "geom_point() now uses shape 19 instead of 16. This looks much better on the default Linux graphics device. (It’s very slightly smaller than the old point, but it shouldn’t affect any graphics significantly)."

library(ggplot2)
ggplot(mtcars) +
  geom_point(aes(wt, qsec),
             size  = 8,
             stroke = 0,
             shape=16,
             alpha = .3)

enter image description here

like image 94
Stedy Avatar answered Sep 22 '22 16:09

Stedy