将不同的主题分配给不同的方面

时间:2016-04-02 15:50:57

标签: r ggplot2 facet

我想知道如果只使用ggplot,可以将不同的主题分配给不同的方面。

这个问题与this one有关,我觉得@baptiste提供的解决方案应该是最好的。

使用他的代码我获得了以下情节:

enter image description here

有了这些数据:

etc

这段代码:

                    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

是否可以使用隐藏与图7,8和9相关的所有元素的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") ,同时仍然返回ggplot对象?

0 个答案:

没有答案