gpt4 book ai didi

r - 时钟中的时间显示,r 中的 xy 散点图

转载 作者:行者123 更新时间:2023-12-04 10:01:07 25 4
gpt4 key购买 nike

我想创建以下类型的图。但是不知道是否已经存在任何包,因为我找不到一个。
数据:

myd <- data.frame (X = 1:5, Y = c(0.8, 0.6, 0.7, 0.75,  0.1), 
clockd = c(12.05, 12.25, 12.45, 1.30, 2.1))

时钟是时间 12.05 是 12 点过去分钟。我不知道在 R 中输入时间的合适单位。
plot (myd$X, myd$Y)

编辑:
红色和绿色箭头代表时钟中时钟臂的小时和微小位置。
enter image description here

最佳答案

clockplot<-function(x, y, h, m, r, border="black", col="lightblue", 
col.hour="darkblue", col.min="red"){
#x and y are the coordinates of the clock
#h and m the hour (base 12) and minutes
# r the radius of the clock
t<-seq(0,2*pi,by=0.01)
x.c<-r*cos(t)+x
y.c<-r*sin(t)+y

t.h<-pi/2 - 2*pi*(h-m/60)/12
x.h<-0.5*r*cos(t.h)+x
y.h<-0.5*r*sin(t.h)+y

t.m<-pi/2 - 2*pi*m/60
x.m<-r*cos(t.m)+x
y.m<-r*sin(t.m)+y

polygon(x.c,y.c,col=col, border=border)
segments(x,y,x.h,y.h,col=col.hour)
segments(x,y,x.m,y.m,col=col.min)
}

myd <- data.frame (X = 1:5, Y = c(0.8, 0.6, 0.7, 0.75, 0.1),
clockd = c(12.05, 12.25, 12.45, 1.30, 2.1))
myd$hour<-myd$clockd%/%1
myd$min<-myd$clockd%%1 *100

plot(myd$X, myd$Y, type="l", asp=1)
apply(myd,1,function(x)clockplot(x[1],x[2],x[4],x[5], r=0.25))

enter image description here

关于r - 时钟中的时间显示,r 中的 xy 散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14854370/

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