简体   繁体   English

如何在 R-Studio 的 plot 窗格中显示树状图

[英]How can I show a dendrogram in the plot pane in R-Studio

I am producing a dendrogram using the following code:我正在使用以下代码生成树状图:

#Hierarchial Clustering
hc<-hclust(distance_matrix,method='average')
plot(hc, cex=0.35, hang=-1)

在此处输入图像描述

The plot shows in the RMD window but not in the plot pane. plot 显示在 RMD window 中,但不在 plot 窗格中。 How can I make it show-up in the plot pane?如何让它显示在 plot 窗格中?

I have tried updating RStudio.我已经尝试更新 RStudio。

I have tried running:我试过运行:

dev.off()

and

options(device = "RStudioGD")

None of these solutions worked.这些解决方案都没有奏效。 How can I show the dendrogram in the plot pane?如何在 plot 窗格中显示树状图?

In general you can send chunk outputs to display inline or in the console.通常,您可以将块输出发送到内联或控制台中显示。 So at the top of the document you just add:因此,您只需在文档顶部添加:

editor_options: 
  chunk_output_type: console

Then your plots (including your dendrogram) should appear in the viewer pane.然后你的图(包括你的树状图)应该出现在查看器窗格中。

You can also toggle this option through the GUI in Rstudio by selecting the arrow next to the 'gear' icon at the top of the editor window and select 'Chunk Output in Console'. You can also toggle this option through the GUI in Rstudio by selecting the arrow next to the 'gear' icon at the top of the editor window and select 'Chunk Output in Console'. 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM