Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ggplot increase size of points

I have a scatter plot that includes different colours for different types of sales as well as different sizes based on the amount of the sales. However, the points are currently very small and I want to increase them. Is there a way to increase all points in the chart? I tried adding scale_size_area(scale = 5) but the points keep the same size.

My code is this

ggplot(abc, aes(x = year, y = amount, color = type, size=amount)) +
  geom_point()+
  guides(color = guide_legend(override.aes = list(size=5)))+
  labs(y= "Amount sold", 
       x = "Year",
       title="",
       fill="Type") +
  scale_size_continuous(name="Size of sales") +
  theme_classic()

and my dataset looks as follows:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

structure(list(year = c(2009L, 2011L, 2012L, 2012L, 2012L, 2013L, 
2013L, 2014L, 2014L, 2014L, 2014L, 2014L, 2015L, 2015L, 2015L, 
2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2017L, 2017L, 
2017L, 2017L), country = c("Spain", "France", "France", "Italy", 
"Spain", "France", "Spain", "Italy", "France", "Italy", "Italy", 
"Italy", "Spain", "Italy", "Italy", "Spain", "Portugal", "Spain", 
"France", "Spain", "Spain", "Italy", "Portugal", "Italy", "France", 
"Spain"), type = c("Food", "Food", "Food", "Food", "Food", "Food", 
"Food", "Food", "Food", "Metal", "Food", "Food", "Food", "Food", 
"Food", "Cars", "Food", "Cars", "Cars", "Food", "Metal", "Cars", 
"Metal", "Food", "Food", "Cars"), amount = c(0.164692692, 1.47320717, 
2.87002149, 0.040626329, 0.110603352, 0.006904824, 0.123085039, 
0.024957478, 4.1241304, 0.499484718, 0.060575151, 0.171695527, 
2.106156361, 0.915858692, 0.056212947, 1.65235, 1.167061203, 
0.046784638, 0.490756212, 0.328276233, 0.189537764, 0.954012362, 
0.470978739, 0.078503892, 0.253975843, 0.2738115)), class = "data.frame", row.names = c(NA, 
-26L))

Thank you very much!

>Solution :

Add range= to your scale_size_continuous. An exaggerated example:

ggplot(abc, aes(x = year, y = amount, color = type, size=amount)) +
  geom_point()+
  guides(color = guide_legend(override.aes = list(size=5)))+
  labs(y= "Amount sold", 
       x = "Year",
       title="",
       fill="Type") +
  scale_size_continuous(name="Size of sales", range=c(2, 20)) +
  theme_classic()

ggplot with big dots

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading