ggdendrogram旋转右侧的ggplot轴标签,用于绘图

时间:2014-07-08 15:52:27

标签: r plot ggplot2 plotly ggdendro

我正在尝试使用ggplot2(更具体地说是ggdendro::ggdendrogram)在R中生成一个合适的树形图,因为我想与我的合作者在图表上分享它,目前我认为不能用api生成一个带有情节的树状图。

我主要遇到了"轴"旋转树形图时标记:

require(ggplot2)
require(ggdendro)
hc<-hclust(dist(iris[,1:4]),method="ward.D2")
ggd<-ggdendrogram(hc,rotate=TRUE)
ggd+scale_y_reverse()

这会产生以下图表,其中刻度标签位于错误的一侧: Clustering with tick labels on the wrong side

我想在执行plot(as.dendrogram(hc),horiz=TRUE)时获得与R基础图形类似的结果 Correct labels base graph

作为奖励,我希望能够单独为叶子(刻度)标签着色以及绘制rect.hclust - 像盒子一样,但这不是绝对必要的。我确实知道我的方式有点ggplot2语法,所以不需要解释所有可能的解决方案。

如果相关请在下面找到我的sessionInfo(),我在Ubuntu 12.04 LTS服务器上使用R到Rstudio服务器:

sessionInfo()
 R version 3.1.0 (2014-04-10)
 Platform: x86_64-pc-linux-gnu (64-bit)

 locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C                LC_COLLATE=C         LC_MONETARY=C        LC_MESSAGES=C        LC_PAPER=C          
 [8] LC_NAME=C            LC_ADDRESS=C         LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods   base     

 other attached packages:
 [1] ggdendro_0.1-14       cluster_1.15.2        plotly_0.4            RJSONIO_1.2-0.2       RCurl_1.95-4.1        bitops_1.0-6          devtools_1.5         
 [8] extrafont_0.16        RColorBrewer_1.0-5    scales_0.2.4          vegan_2.0-10          lattice_0.20-29       permute_0.8-3         splitstackshape_1.2.0
 [15] data.table_1.9.2      BurStMisc_1.00        reshape2_1.4          xlsx_0.5.5            xlsxjars_0.6.0        rJava_0.9-6           ggplot2_0.9.3.1      
 [22] plyr_1.8.1           

 loaded via a namespace (and not attached):
 [1] MASS_7.3-32      Rcpp_0.11.1      Rttf2pt1_1.3     colorspace_1.2-4 digest_0.6.4     evaluate_0.5.5   extrafontdb_1.0  formatR_0.10     grid_3.1.0      
 [10] gtable_0.1.2     httr_0.3         knitr_1.6        labeling_0.2     memoise_0.2.1    munsell_0.4.2    parallel_3.1.0   proto_0.3-10     stringr_0.6.2   
 [19] tools_3.1.0      whisker_0.3-2

0 个答案:

没有答案
相关问题