0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ShinyでPlotlyのevent_data関数を使う方法

Posted at

R言語やShinyアプリで、グラフを表示したい場合は、まず、plotlyのパッケージを下記のように読み込みます。

library(plotly)

そして、グラフ表示したいデータ(仮にgraphDataとします。)を下記のように記し、実行すると、グラフが描かれます。

plot_ly(graphData, source = “A”)

描かれたグラフをクリックした情報を取得したい場合は、下記のように記し、実行します。

event_data(“plotly_click”, source = “A”)

上記を実行すると、クリック箇所のx座標、y座標、クリックしたグラフが描画された順番(curveNumber)、クリックしたグラフ上のcurveNumber上でのグラフが描画された順番(pointNumber)が取得できます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?