gpt4 book ai didi

r - 向图表添加来源或标题

转载 作者:行者123 更新时间:2023-12-03 19:05:11 25 4
gpt4 key购买 nike

有没有办法在 Plotly 中为图表添加数据源/标题,类似于在 ggplot 中可以做的事情使用标题参数:

labs(caption = "source: data i found somewhere") 

也就是说,我们可以在图表的右下角以较小的字体显示数据源。

最佳答案

annotationplotly 中提供了一种向图表添加标题的简单方法:

library(plotly)
plot_ly(x=~hp, y=~mpg, data=mtcars, type="scatter", mode="marker") %>%
layout(annotations =
list(x = 1, y = -0.1, text = "Source: data I found somewhere.",
showarrow = F, xref='paper', yref='paper',
xanchor='right', yanchor='auto', xshift=0, yshift=0,
font=list(size=15, color="red"))
)

enter image description here .

更多详情在 herehere .

关于r - 向图表添加来源或标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45103559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com