Skip to content

Instantly share code, notes, and snippets.

@cimentadaj
Last active August 16, 2016 22:29
Show Gist options
  • Save cimentadaj/86fb2bd4c448151117404ec410f7595f to your computer and use it in GitHub Desktop.
Save cimentadaj/86fb2bd4c448151117404ec410f7595f to your computer and use it in GitHub Desktop.
# Create boxplot and remove the outliers
o <- ggplot(housing[!is.na(housing$region), ], aes(x=region, y=Land.Price.Index)) + geom_boxplot(outlier.shape = NA)
# The options from scale_*_discrete are practically the same as scale_*_continuous except limits.
# Remember that limits controls the minimum and maximum of the chosen axis. Given that this is
# a categorical discrete axis, it doesn't make any sense to define neither. Instead, you control the order of categories.
o + scale_x_discrete(name="Region",
breaks=waiver(),
labels=waiver(),
limits=c("N. East", "South", "West", "Midwest")) # Notice how I change the order of the categories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment