2017-07-08 7 views
1

私のアルゴリズムは、対称行列mを計算します。私がする必要があるのは、たとえばimageのようなプロットを作成し、このプロットをクリック可能にして、click callbackがクリックされた行列エントリの位置を表示するようにすることです。私はRでこれをどうやって行うことができますか?Rマトリクスプロットの位置をクリック

m = createMatrix(data); 
image(1:matrixSize,1:matrixSize,m); 

答えて

1

パッケージをplotlyに基づいて試してみてください。
あなたのお役に立てば幸いです。

# A symmetrix matrix 
mtx <- cor(matrix(rnorm(1000),ncol=5)) 

# From wide to long format 
library(reshape) 
mtx.long <- melt(mtx) 

# Create an image plot of the matrix 
library(ggplot2) 
p <- ggplot(data=mtx.long, aes(x=X1, y=X2, fill=value))+geom_raster() 

# Create an interactive plot 
library(plotly) 
ggplotly(p) 

enter image description here

+0

おかげで、あなたのコードは魅力のように働きました –

関連する問題