1

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:

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!

0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.