首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编辑gtrendsR的图形输出

编辑gtrendsR的图形输出
EN

Stack Overflow用户
提问于 2015-12-31 16:26:55
回答 1查看 180关注 0票数 1
代码语言:javascript
复制
library(gtrendsR)
library(ggplot2)
usr <- "xxxxxx@gmail.com"
psw <- "XXXXX"
gconnect(usr, psw) 
climate_trend <- gtrends(c("climate", "cop21", "global warming"), res="week")

plot(climate_trend, main="whatttt", xlab="x")

尽管没有收到错误,但使用main=xlab=等绘图编辑选项不会在绘图输出中创建更改。我曾考虑过将ggplot2gtrendsR结合使用,但这需要我将list数据转换为我遇到麻烦的data.frame

我很欣赏使用gtrendsR编辑绘图输出的轴的任何输入。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-31 17:17:14

您可能感兴趣的数据框架只是climate_trend$trend元素。下面是我为获得一个ggplot2图所做的工作:

代码语言:javascript
复制
library(gtrendsR)
library(ggplot2)
library(reshape2)

usr <- "xxxx@gmail.com"   # any gmail address and pw will do here
psw <- "xxxxx"
gconnect(usr, psw) 
climate_trend <- gtrends(c("climate", "cop21", "global warming"), res="week")

# plot(climate_trend$trend, main="whatttt")

# now for ggplot 2
tdf <- climate_trend$trend
mdf <- melt(tdf,id.vars=c("start","end"))
ggplot(data=mdf,aes(x=start,y=value,color=variable)) + 
  geom_line() + geom_point() +
  labs(title="Whatttt")

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34549009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档