【问题标题】:How to get correlation matrix as upper half of the matrix with splom using plotly in R如何在 R 中使用 plotly 将相关矩阵作为矩阵的上半部分
【发布时间】:2021-09-16 00:57:11
【问题描述】:

我将 splom 用于配对图。我想用 R 碱基对图中提供的相关值绘制对图。我没有找到在 R 中使用 splom 和 plotly 的配对图的相关性显示。我通过下面的链接来绘制配对图,因为他们没有提到具有相关值的配对图。

link 用于绘制配对图。

使用 plotly 使用 spolm 进行所需的可视化:

在 R 中使用 plotly 的 splom 是否可以实现所需的可视化?

【问题讨论】:

  • 你如何得到你的基础情节?

标签: r plotly r-plotly


【解决方案1】:

我还添加了一个基本示例,以使此答案更具信息性。 解决方案之一是使用GGally::ggpairsplotly::ggplotly 函数。当然plotly::ggplotly返回的情节会是互动的。

# Base plot

panel.cor <- function(x, y) {
  usr <- par("usr")
  on.exit(par(usr))
  par(usr = c(0, 1, 0, 1))
  r <- round(cor(x, y), digits = 2)
  # possible to edit the size
  text(0.5, 0.5, r)
}

pairs(iris[, 1:4],
  upper.panel = panel.cor
)

## GGally solution - plotly
## assume GGally and plotly are installed

pm <- GGally::ggpairs(iris[, 1:4])
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2
class(pm)
#> [1] "gg"       "ggmatrix"
plotly::ggplotly(pm)

reprex package (v2.0.0) 于 2021-07-09 创建

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-03
    • 2012-01-03
    • 1970-01-01
    • 2012-10-15
    • 1970-01-01
    • 2019-04-15
    • 2019-12-07
    • 1970-01-01
    相关资源
    最近更新 更多