gpt4 book ai didi

r - 降水图,或基于顶轴的镜像直方图

转载 作者:行者123 更新时间:2023-12-04 19:06:40 25 4
gpt4 key购买 nike

我喜欢绘制简单的时间序列数据和覆盖降水数据。以下代码为常用数据绘制一条线,并为降水数据添加条形图(或直方图条)。

D # a simple (zoo) time series
P # a simple (zoo) time series of precipitation
plot(D, type="l")
lines(P, type="h", lwd=5)

但是条形图基于 y=0 轴并向上上升。但是在水文学中通常是基于顶部轴和向下“流动”的降水条。 D有任意的 y 范围,所以我更喜欢一个解决方案,它确实为 P 的基线固定了一个值.

我在谷歌上搜索了很多,但没有找到如何在没有 ggplot 的情况下在 R 中做到这一点,也没有像水流图这样的额外包。

最佳答案

不确定我是否理解正确,所以这是我的解释。
不知道这是否适用于 zoo对象也是如此。

# Create some mock data
x<-runif(20,0,100)
y<-runif(20,0,100)

# This is the normal topwards plot
plot(x,y,type="h")

enter image description here
# And this is the downwards plot
plot(x, y, ylim = rev(range(y)),type="h")

enter image description here

关于r - 降水图,或基于顶轴的镜像直方图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22972466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com