user13975917
user13975917

Reputation:

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

Can you please help me understand why my x axis look weird and help me resolve the issue?

Upvotes: 0

Views: 227

Answers (1)

Bast_B
Bast_B

Reputation: 143

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

Upvotes: 1

Related Questions