R像MATLAB绘图

数值变量绘图

boxplot(count ~ spray, data = InsectSprays, col = “lightgray”)

par(mfrow = c(5, 4), tcl = -0.3, family = ‘serif’,
cex.main = 0.75, cex.axis = 0.75, cex.lab = 0.75, mar = c(2, 2, 2, 2))
for(i in seq(length(Xt))){
ts.plot(mean.single.sample.results[,i] %>% unname(),
gpars = list(xlab = " “, #“iterations”,
ylab =” ", # “cumulative average values”,
lwd = 1, col = 1, lty = 1))
title(paste(“wine tastor”, i, sep = " "))
}
============================ ggplot2常用参数说明 =============================

数据格式

data.plot = data.frame(t = t, actu = x.actu, train = x.train)

绘图命令

ggplot(data.plot, aes(t)) + geom_point(aes(y = train), size = 2, colour = “green”, aplha = 0.5) + # alpha 制定透明度
geom_line(aes(y = actu), linetype = 2, size = 2, colour = “black”) + geom_point(aes(y = actu), colour = “black”) + # linetype 制定线型
geom_line(aes(y = simu), colour = “red”) + geom_point(aes(y = simu), colour = “red”) + # size 线条粗细和标记大小
xlab(“t”) + ylab(“x(t)”) + ggtitle(paste(“polynomial order=”, poly_order, sep = “”))

library(ggplot2)
library(reshape2)

for(i in 1:7){
plt_ts = resample_numeric_ts[, c(2, 5*i+(-2:2))] %>%
reshape2::melt(., id = “time”) # 数据变形 宽 --> 长
windows()
print(
qplot(time, value, data = plt_ts, geom = “line”, group = variable) +
facet_grid(variable~., scale = “free_y”)
)
}

head(economics, 6)
A tibble: 6 x 6
date pce pop psavert uempmed unemploy

1 1967-07-01 507. 198712 12.5 4.50 2944
2 1967-08-01 510. 198911 12.5 4.70 2945
3 1967-09-01 516. 199113 11.7 4.60 2958
4 1967-10-01 513. 199311 12.5 4.90 3143
5 1967-11-01 518. 199498 12.5 4.70 3066
6 1967-12-01 526. 199657 12.1 4.80 3018
em = melt(economics, id = “date”)
qplot(date, value, data = em, geom = “line”, group = variable) +
facet_grid(variable ~., scale = “free_y”)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值