阅读权限 255 威望 0 级论坛币 2444 个 通用积分 60.5031 学术水平 69 点 热心指数 78 点 信用等级 44 点 经验 4348 点 帖子 160 精华 0 在线时间 399 小时 注册时间 2008-4-14 最后登录 2024-7-30
# Make up some dummy data
set.seed(1705190905)
dfDmmy <-
merge(
data.frame( quarter = c(1:4) ),
data.frame( year = c(2006:2009) )
)
dfDmmy$mid <-
1.5*exp( -0.2*( seq.int( nrow(dfDmmy) ) - 1 )*
exp( rnorm( nrow(dfDmmy), sd = 0.05 ) ) )
dfDmmy$upper <- with( dfDmmy, mid + runif( length(mid) )*mid/2 )
dfDmmy$lower <- with( dfDmmy, mid - runif( length(mid) )*mid )
# Set up plot
par(family = "serif")
plot(
NA, type = "n",
xlim = range( seq.int( nrow(dfDmmy) ) ), ylim = c(-0.5, 2.5),
xlab = NA_character_, ylab = NA_character_, axes = FALSE
)
# Axes
with(
dfDmmy,
{
axis( side = 1, at = seq_along(quarter), labels = quarter,
lwd = 0, lwd.ticks = 1 )
lapply(
unique(year),
function(i)
mtext( text = as.character(i), side = 1, line = 2,
at = mean( which( year == i ) ), adj = 0.5, padj = 1 )
)
}
)
abline( h = par("usr")[3] )
axis( side = 2, at = c(-1:5/2), labels = sprintf("%5.2f", -1:5/2),
las = 1, lwd = 0, lwd.ticks = 1 )
abline( v = par("usr")[1] )
# Title
# mtext(
# text = expression( paste( "Statistics with BCPNN methods, ", italic(IC) ) ),
# side = 3, adj = 0, xpd = FALSE
# )
# text(
# x = par("usr")[1] - par("mar")[2]*par("cxy")[1],
# y = par("usr")[4] + par("cxy")[2]/2,
# labels = expression( paste( "Statistics with BCPNN methods, ", italic(IC) ) ),
# adj = c(0, 0), xpd = NA
# )
windowsFonts( SONG = windowsFont("TT SimSun") )
text(
x = par("usr")[1] - par("mar")[2]*par("cxy")[1],
y = par("usr")[4] + par("cxy")[2]/2,
labels = "BCPNN",
family = "serif", adj = c(0, 0), xpd = NA
)
text(
x = par("usr")[1] - par("mar")[2]*par("cxy")[1] + strwidth("BCPNN"),
y = par("usr")[4] + par("cxy")[2]/2,
labels = "\u{6CD5}\u{7EDF}\u{8BA1}\u{91CF}\u{FF0C}",
family = "SONG", adj = c(0, 0), xpd = NA
)
text(
x =
par("usr")[1] - par("mar")[2]*par("cxy")[1] +
strwidth("BCPNN\u{6CD5}\u{7EDF}\u{8BA1}\u{91CF}\u{FF0C}") + par("cxy")[1],
y = par("usr")[4] + par("cxy")[2]/2,
labels = "IC",
family = "serif", font = 3, adj = c(0, 0), xpd = NA
)
# Horizontal reference line
abline( h = 0, lty = 3, col = "blue" )
# Plot the data
with(
dfDmmy,
{
# Intervals
dvX <- seq_along(mid)
# mapply(
# lines,
# x =
# apply( cbind( seq_along(lower) - 0.1, seq_along(lower) + 0.1 ), 1, I ),
# y = apply( cbind( lower, lower ), 1, I )
# )
mapply(
segments,
x0 = lapply(dvX - 0.1, I), x1 = lapply(dvX + 0.1, I),
y0 = lapply(lower, I)
)
# mapply(
# lines,
# x =
# apply( cbind( seq_along(upper) - 0.1, seq_along(upper) + 0.1 ), 1, I ),
# y = apply( cbind( upper, upper ), 1, I )
# )
mapply(
segments,
x0 = lapply(dvX - 0.1, I), x1 = lapply(dvX + 0.1, I),
y0 = lapply(upper, I)
)
# mapply(
# lines,
# x = apply( cbind( seq_along(lower), seq_along(upper) ), 1, I ),
# y = apply( cbind( lower, upper ), 1, I )
# )
mapply(
segments,
x0 = lapply(dvX, I), y0 = lapply(lower, I), y1 = lapply(upper, I)
)
# Points and lines
points( mid, type = "o" )
}
) 复制代码
Output: