2
私はプロット的なインタラクティブな図形でラベルとしてテキストを持ち、詳細についてはこれらのラベルの上にカーソルを置いておきたいと思います。テキストラベルとホバーテキストをプロットして使用できますか?
しかし、プロットしても、同じコード行にテキストラベルとホバーテキストが表示されません。私は必然的にテキストラベルの後ろにあり、単純な散点を使用したくない。
テキストラベルを表示してテキストを表示できるように、以下のコードを修正する方法はありますか?
ありがとうございました。あなたが解決策に似た何かができる
# Load packages
require(ggplot2)
require(plotly)
# Example data
data(iris)
str(iris)
# Create new columns - with more information
iris$Symbol <- c("Se", "Ve", "Vi")[iris$Species]
iris$PlantedBy <- c("Bruce", "Joe", "Eliza")[iris$Species]
# Create in ggplot
ggplot(iris, aes(x = Sepal.Length, y =Sepal.Width, colour = Species,
label = Symbol)) +
geom_text(fontface = "bold", size = 6) +
theme_classic() +
theme(legend.position = "none")
# Plotly - point with hover text
plot_ly(iris, x = ~Sepal.Length, y = ~Sepal.Width, type = 'scatter',
mode = 'text',
text = ~Symbol)
# Plotly - point with hover text (does not work)
plot_ly(iris, x = ~Sepal.Length, y = ~Sepal.Width, type = 'scatter',
mode = 'text',
text = ~Symbol,
hoverinfo = 'text',
text = ~paste('Species: ', Species,
'</br> Planted by: ', PlantedBy))