2017-07-14 93 views
1

有没有办法到数据源/字幕添加到Plotly图表,用什么可以在ggplot完成的文字说明论点相似:plotly添加源或标题为图表

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

即,所以我们可以以较小的字体显示图表右下角的数据源。

回答

1

annotation提供了一个简单的方法来标题中plotly添加到图表:

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

+0

感谢Marco,但ggplot已经有实验室了。我的问题是专门做这件事,但情节剧本。 – chrisjacques

+0

@chrisjacques我编辑了我的答案。现在你可以找到一种方法来为你的图表添加一个标题。如果此解决方案可以帮助您,请考虑放弃它。 –