gpt4 book ai didi

r - 如何使 googlevis 图在 R 中自动适应屏幕

转载 作者:行者123 更新时间:2023-12-04 11:33:21 24 4
gpt4 key购买 nike

我正在尝试通过 googleVis 在 R 中制作图表.
您如何使图表自动适应屏幕的大小,或者更确切地说,适合浏览器的大小?

library('googleVis')
Column <- gvisColumnChart(df,
options=list(legend='none'))
plot(Column)
cat(createGoogleGadget(Column), file="columnchart.xml")

最佳答案

从文档中不是很清楚,谁似乎希望您使用像素,例如 width = 200以像素为单位,但您可以使用 这个词“自动”这很好地扩展。

所以摘自我的一个功能:

 # where plotdt has my data with columns px and py
plot1 <- gvisBarChart(plotdt,
xvar = px,
yvar = c(py),
options = list(width = "automatic",
height = "automatic")

请注意您的情况,添加到您的选项列表
gvisColumnChart(df,
options=list(legend='none',
width = "automatic",
height = "automatic"))

希望这对其他人有帮助。

另外,有关 configuration options 的更多信息的有用链接.这是用于条形图,因此请在页面左侧为您选择正确的图表/表格类型。

测试一下

由于 df上面没有数据对于那些想玩这个的人:
library('googleVis')

# some test data, add your own
df <- data.frame(x = c(1,2,3),
y = c(2,4,6))

plotdata <- gvisColumnChart(df,
options=list(legend='none',
width = "automatic",
height = "automatic"))

plot(plotdata)

关于r - 如何使 googlevis 图在 R 中自动适应屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19302141/

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