I am making a chart in ggplot
to show the amount of crime that occurs in a certain year. The graph comes out well, but the x-axis values aren't showing.
I then try manually plotting the values using scale_x_continuous
and scale_x_discrete
.
With scale_x_continuous(limits=c(0,500000))
the following error occurs:
Error: Discrete value supplied to continuous scale
Here is the code I am using:
ggplot(london2012,aes(london2012$Crime, london2012$X2012)) +
geom_col(aes(fill=as.factor(london2012$Crime)), show.legend = FALSE) +
coord_flip() + theme_classic() + theme(axis.text = element_text(face =
"bold", color = "black")) +
theme( axis.title.x=element_blank(),
axis.title.y =element_blank())
I am using the same code for another dataset and it comes out correctly
ggplot(SouthAfricanCrimeWC,aes(SouthAfricanCrimeWC$Category, SouthAfricanCrimeWC$X2010)) +
geom_col(aes(fill=as.factor(SouthAfricanCrimeWC$Category)), show.legend = FALSE) +
coord_flip() + theme_classic() + theme(axis.text = element_text(face = "bold",color = "black")) +
theme(axis.title.x=element_blank(),
axis.title.y=element_blank())
Any suggestions that may help it work?