x axis Error when plotting with dotplot (binaxis = "y") - ggplot

Solution 1:

Maybe you were thinking about using geom_point instead of geom_dotplot ? Your axis is discrete because you used a factor variable but indeed you have a blank space on the right. Maybe you could instead of using two dataset, doing the ggplot on one and using the color variable you created to color the right points.

   storeProfit = storeProfit %>%mutate(color = (min(totalProfit) == totalProfit | max(totalProfit) == totalProfit))
  

ggplot(data = storeProfit, aes(x = factor(STORE), y = totalProfit,fill=color)) +
  geom_dotplot(binaxis = "y", fill = "light blue")+
  labs(title = "Total softdrink profit per Store", x = "Store", y = "Total Profit (USD$)") +
  theme(axis.text.x=element_text(angle=90,hjust=1))+
scale_fill_manual(c("light blue","red")) 

This is the best I can think without a reproducible dataset