平滑和操纵 x 轴
Smoothing and manipulating x-axis
我目前正在制作一张关于超过降水极端事件概率的图表。但是,我正在努力处理代码。
这是我目前得到的:
PE2010 <- read.table(file="C:/Users/PE2001-2010.txt",header=TRUE)
plot(PE2010$Pre ~ PE2010$PE,
col = "red",
xlab = "Overschrijdingskans",
ylab = "Neerslagintensiteit (mm/d)",
main = "Overschrijdingskans voor de 3 simulaties")
结果如图:
我想做什么:
- 我希望 x 轴的范围不是 0 到 1,而是从 1 到 0
- 如果 x 轴上只显示值 1、0.1、0.01 和 0.001 就好了
- 我希望将数据表示为平滑曲线,而不是像现在这样的点。但是,当使用 "lines" 函数时,会出现奇怪的结果。
总结一下,我希望结果是这样的:
没有您的实际数据,很难完全正确,但这可能是您想要的一个很好的近似值:
# an index that will put the data in order from left to right
indx <- order(PE2010$PE)
plot(y =PE2010$Pre[indx],
x = PE2010$PE[indx],
col = "red",
xlab = "Overschrijdingskans",
ylab = "Neerslagintensiteit (mm/d)",
main = "Overschrijdingskans voor de 3 simulaties",
type = "l",
# log transformt the x-axis
log = 'x',
# reverse the x axis
xlim = range(PE2010$PE,na.rm=T)[2:1],
# don't include the default axes
axes=F
)
# make the axes
box()
axis(2)
axis(1,at=c(1, 0.1, 0.01,0.001 ))
我目前正在制作一张关于超过降水极端事件概率的图表。但是,我正在努力处理代码。
这是我目前得到的:
PE2010 <- read.table(file="C:/Users/PE2001-2010.txt",header=TRUE)
plot(PE2010$Pre ~ PE2010$PE,
col = "red",
xlab = "Overschrijdingskans",
ylab = "Neerslagintensiteit (mm/d)",
main = "Overschrijdingskans voor de 3 simulaties")
结果如图:
我想做什么:
- 我希望 x 轴的范围不是 0 到 1,而是从 1 到 0
- 如果 x 轴上只显示值 1、0.1、0.01 和 0.001 就好了
- 我希望将数据表示为平滑曲线,而不是像现在这样的点。但是,当使用 "lines" 函数时,会出现奇怪的结果。
总结一下,我希望结果是这样的:
没有您的实际数据,很难完全正确,但这可能是您想要的一个很好的近似值:
# an index that will put the data in order from left to right
indx <- order(PE2010$PE)
plot(y =PE2010$Pre[indx],
x = PE2010$PE[indx],
col = "red",
xlab = "Overschrijdingskans",
ylab = "Neerslagintensiteit (mm/d)",
main = "Overschrijdingskans voor de 3 simulaties",
type = "l",
# log transformt the x-axis
log = 'x',
# reverse the x axis
xlim = range(PE2010$PE,na.rm=T)[2:1],
# don't include the default axes
axes=F
)
# make the axes
box()
axis(2)
axis(1,at=c(1, 0.1, 0.01,0.001 ))