plotly包:讓ggplot2的靜態圖片變得可交互
Plotly 是個交互式可視化的第三方庫,官網提供了Python,R,Matlab,JavaScript,Excel的接口,因此我們可以很方便地在這些軟件中調用Plotly,從而實現交互式的可視化繪圖。
plotly支持facet,不過當facet的圖形超過9個以后,legend處會出現bug。
栗子:
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
plot_ly(d, x = ~carat, y = ~price, color = ~carat,size = ~carat, text = ~paste("Clarity: ", clarity))
參考資料:
【1】官網 (https://plot.ly/r/)
【2】plot_ly 詳細參數說明 (https://plot.ly/r/reference/)