-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
library(data.table)
library(ggplot2)
# Labeller function
iris_lblr <- function(var, value) {
labels <- c('setosa'='SET', 'versicolor'='VERS', 'virginica'='VIRG')
if (var=='Species') {
return ( labels[value])
}
}
# using data.table just for ease of filtering/mutation
dt <- data.table(iris)
# This plot works fine - short caps labels are applied correctly
ggplot(dt, aes(x=Sepal.Length, y=Petal.Length)) + geom_point() + facet_grid(.~Species, labeller=iris_lblr)
# this plot also has the correct CAPS labels applied, and the middle facet is missing
ggplot(dt[Species!='versicolor'], aes(x=Sepal.Length, y=Petal.Length)) + geom_point() + facet_grid(.~Species, labeller=iris_lblr)
dt[, Species:=as.character(Species)]
# This plot shows "VERS" where it should show "VIRG".
ggplot(dt[Species!='versicolor'], aes(x=Sepal.Length, y=Petal.Length)) + geom_point() + facet_grid(.~Species, labeller=iris_lblr)Metadata
Metadata
Assignees
Labels
No labels