我試圖通過使用scale_colour_discrete
將下標添加到我的ggplot2 geom_point顏色圖例中。類似的問題彈出hereggplot2圖例因子標籤中的下標(或其他數學公式)
p <- ggplot(myData, aes(myFeature1,myFeature2))
p <- p + geom_point(aes(colour = myFeature3)) + facet_grid(n ~ cond)
p <- p + scale_colour_discrete(breaks = levels(myData$myFeature3), labels = c(expression(myFeature3[1]),expression(myFeature3[2]))
然而,會出現以下錯誤:在FUN 誤差(X [[1L]],...): 不能強制類型 '符號' 到類型 '雙' 的矢量
這個錯誤不會發生,不在labels
定義expression
。它會出現在expression
裏面。
關於這個問題的任何想法? scale_colour_discrete
只是不適用於expression
?是否有另一種方法可以將下標加入這些圖例因子名稱中?
非常感謝!