該函數返回一個文本,可以在網頁等中用作alt-text。目前它將使用alt
標簽,添加+ labs(alt = <...>)
,或者返回一個空字符串,但將來它可能會嘗試生成一個來自繪圖中存儲的信息的替代文本。
例子
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point()
# Returns an empty string
get_alt_text(p)
#> [1] ""
# A user provided alt text
p <- p + labs(
alt = paste("A scatterplot showing the negative correlation between engine",
"displacement as a function of highway miles per gallon")
)
get_alt_text(p)
#> [1] "A scatterplot showing the negative correlation between engine displacement as a function of highway miles per gallon"
相關用法
- R ggplot2 geom_qq 分位數-分位數圖
- R ggplot2 geom_spoke 由位置、方向和距離參數化的線段
- R ggplot2 geom_quantile 分位數回歸
- R ggplot2 geom_text 文本
- R ggplot2 geom_ribbon 函數區和麵積圖
- R ggplot2 geom_boxplot 盒須圖(Tukey 風格)
- R ggplot2 geom_hex 二維箱計數的六邊形熱圖
- R ggplot2 geom_bar 條形圖
- R ggplot2 geom_bin_2d 二維 bin 計數熱圖
- R ggplot2 geom_jitter 抖動點
- R ggplot2 geom_point 積分
- R ggplot2 geom_linerange 垂直間隔:線、橫線和誤差線
- R ggplot2 geom_blank 什麽也不畫
- R ggplot2 geom_path 連接觀察結果
- R ggplot2 geom_violin 小提琴情節
- R ggplot2 geom_dotplot 點圖
- R ggplot2 geom_errorbarh 水平誤差線
- R ggplot2 geom_function 將函數繪製為連續曲線
- R ggplot2 geom_polygon 多邊形
- R ggplot2 geom_histogram 直方圖和頻數多邊形
- R ggplot2 geom_tile 矩形
- R ggplot2 geom_segment 線段和曲線
- R ggplot2 geom_density_2d 二維密度估計的等值線
- R ggplot2 geom_map 參考Map中的多邊形
- R ggplot2 geom_density 平滑密度估計
注:本文由純淨天空篩選整理自Hadley Wickham等大神的英文原創作品 Extract alt text from a plot。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。