[R] How to decrease size of points?
Rui Barradas
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Wed Sep 30 21:35:37 CEST 2020
Hello,
Inline.
Às 20:01 de 30/09/20, Medic escreveu:
> №1 Medic:
> The code works as I want, but the points (circles) on the plot are too
> big. How to decrease them? Where to insert (for instance) size = 0.8
> for points (circles) on plot?
>
> p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
> ylab("Y") + geom_smooth()
>
> Stage is factor, x and y - continuous
> ===
> №2 Rui Barradas:
> add the scale_size
> p1 + scale_size_manual(values = 0.8)
> ===
> №3 Medic:
> Thanks Rui, but I got:
> Error: Insufficient values in manual scale. 12 needed but only 1 provided.
> (or Error: Continuous value supplied to discrete scale)
> ===
> №4 Rui Barradas:
> Try
> nsize <- length(unique(df1$Stage))
> before the plot and then
> p1 + scale_size_manual(values = rep(0.8, nsize))
> ===
> №5 Medic:
> Rui, your example is very good!
> Now your code works, but not as I want.
>
> Why did I use:
> geom_point(aes(size = Stage)...?
> In order to receive points of DIFFERENT size!
>
> And what does your code do?
> It assigns the same fixed size to ALL points.
If you want different sizes, the main idea is the same, assign the sizes
in scale_size_manual.
Stage is a factor so it has a certain number of levels. Create a numeric
variable, Sizes, from the minimum to the maximum size, set names to its
values and use that vector.
With 0.4 and 0.8 as min and max size, something like
Sizes <- seq(0.4, 0.8, length.out = length(levels(df1$Stage)))
Sizes <- setNames(Sizes, levels(df1$Stage))
p1 + scale_size_manual(values = Sizes)
Hope this helps,
Rui Barradas
>
> I don't need this.
> I sincerely thank you and closing the topic!
>
More information about the R-help
mailing list