I would like to know if by only using ggplot it is possible to assign different themes to different facets.
This question is related to this one where I feel that the solution provided by @baptiste should be the best one.
Using his code I obtained the following plot:
With this data:
RIM BlackBerry Pearl Palm Treo 700p Motorola Q Nokia 9300 Sony Ericsson M600i Sidekick3 id
Compact 6.9 5.7 6.7 4.5 5.1 3.6 Compact
Quality of display 7.5 6.3 7.3 5.1 6.2 3.8 Quality of display
Push email availability 8.2 7.4 6.4 6.4 6.0 4.5 Push email availability
Brand image 8.6 8.5 7.2 6.5 4.5 3.0 Brand image
Comfortable to call 7.4 6.9 6.1 4.2 5.2 3.1 Comfortable to call
High prestige 7.2 6.9 6.8 5.5 4.0 1.2 High prestige
And this code:
data_sub = melt(data_sub)
# Set id as factor
data_sub$id = factor(data_sub$id, levels=unique(data_sub$id))
# Add empty levels to reach 9 levels
levels(data_sub$id) = c(levels(data_sub$id), c((1 + length(unique(data_sub$id))):9))
ggplot(data_sub, aes(x=variable, y=value, fill = "same_for_all") ) +
geom_bar(stat = "identity") +
facet_wrap(~ id, ncol = 3, drop = FALSE) +
scale_fill_manual(values = globals$graphics$color$palette2) +
coord_flip() +
theme(axis.ticks.x = element_blank(),
axis.text.x = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.grid = element_blank(),
legend.position = "none")
Is it possible to use a theme()
that will hide all the element related to the plots 7, 8 and 9, while still returning a ggplot object ?