第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在R圖窗口中組合基礎(chǔ)和ggplot圖形

在R圖窗口中組合基礎(chǔ)和ggplot圖形

MM們 2019-11-25 20:16:56
在R圖窗口中組合基礎(chǔ)和ggplot圖形我想生成一個(gè)具有base和ggplot圖形組合的圖形。以下代碼使用R的基本繪圖函數(shù)顯示我的圖:t <- c(1:(24*14)) P <- 24 A <- 10 y <- A*sin(2*pi*t/P)+20par(mfrow=c(2,2))plot(y,type = "l",xlab = "Time (hours)",ylab = "Amplitude",main = "Time series")acf(y,main = "Autocorrelation",xlab = "Lag (hours)", ylab = "ACF")spectrum(y,method = "ar",main = "Spectral density function",           xlab = "Frequency (cycles per hour)",ylab = "Spectrum")require(biwavelet)t1 <- cbind(t, y)wt.t1=wt(t1)plot(wt.t1, plot.cb=FALSE, plot.phase=FALSE,main = "Continuous wavelet transform",      ylab = "Period (hours)",xlab = "Time (hours)")哪個(gè)生成 這些面板中的大多數(shù)看起來(lái)足以讓我包含在我的報(bào)告中。但是,需要改進(jìn)顯示自相關(guān)的圖。使用ggplot看起來(lái)好多了:require(ggplot2)acz <- acf(y, plot=F)acd <- data.frame(lag=acz$lag, acf=acz$acf)ggplot(acd, aes(lag, acf)) + geom_area(fill="grey") +   geom_hline(yintercept=c(0.05, -0.05), linetype="dashed") +   theme_bw()但是,由于ggplot不是基本圖形,我們無(wú)法將ggplot與布局或par(mfrow)結(jié)合起來(lái)。我怎樣才能用ggplot生成的自相關(guān)圖替換基本圖形生成的自相關(guān)圖?我知道如果我的所有數(shù)據(jù)都是用ggplot制作的話我可以使用grid.arrange但是如果只有一個(gè)圖是在ggplot中生成的話我該怎么辦呢?
查看完整描述

3 回答

?
不負(fù)相思意

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超10個(gè)贊

您可以將print命令與grob和viewport一起使用。
首先繪制基礎(chǔ)圖形,然后添加ggplot

library(grid)# Let's say that P is your plotP <- ggplot(acd, # etc... )# create an apporpriate viewport.  Modify the dimensions and coordinates as neededvp.BottomRight <- viewport(height=unit(.5, "npc"), width=unit(0.5, "npc"), 
                           just=c("left","top"), 
                           y=0.5, x=0.5)# plot your base graphics par(mfrow=c(2,2))plot(y,type #etc .... )# plot the ggplot using the print commandprint(P, vp=vp.BottomRight)



查看完整回答
反對(duì) 回復(fù) 2019-11-26
?
慕標(biāo)琳琳

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊

我是gridGraphics包的粉絲。出于某種原因,我遇到了gridBase的問(wèn)題。

library(ggplot2)library(gridGraphics)data.frame(x = 2:10, y = 12:20) -> datplot(dat$x, dat$y)grid.echo()grid.grab() -> mapgrobggplot(data = dat) + geom_point(aes(x = x, y = y)) pushViewport(viewport(x = .8, y = .4, height = .2, width = .2))    grid.draw(mapgrob)


查看完整回答
反對(duì) 回復(fù) 2019-11-26
  • 3 回答
  • 0 關(guān)注
  • 711 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)