'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?
Solution 1:[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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bast_B |
