提问人:Jackie Reuder 提问时间:11/17/2023 最后编辑:Jon SpringJackie Reuder 更新时间:11/22/2023 访问量:36
按降序排列 y 轴
Arranging y-axis in descending order
问:
我在 R 中有一个算盘图,其 y 轴从底部降序排列。我需要它从顶部下降。abacus_plot() 使用基本 plot() 变量。看似直截了当,但我却空手而归。我的代码:
library(glatos)
abacus_plot(detections_w_events,
location_col= 'deploy_lat', ylab = 'Latitude',
main='Detections by Station', x_res = "12 weeks", x_format = "%b-%y",
col = detections_w_events$color)
目前剧情:
答:
0赞
Chris Holbrook
11/22/2023
#1
Glatos::abacus_plot 将 Y 轴值视为文本,默认情况下,它沿 Y 轴从下到上按反向字母顺序对级别进行排序。尽管使用纬度等数值似乎有悖常理,但您只需要指定唯一的 y 轴级别(包括从下到上的打印顺序)并通过参数将这些级别传递给abacus_plot。这在 ?abacus_plot 中进一步解释。locations
因此,要回答您的问题,请尝试:
# make vector of y-levels to display (with desired order, bottom-to-top along y)
my_locs <- sort(unique(detections_w_events$deploy_lat))
abacus_plot(detections_w_events,
location_col= 'deploy_lat',
locations = my_locs,
ylab = 'Latitude',
main='Detections by Station', x_res = "12 weeks", x_format = "%b-%y",
col = detections_w_events$color)
评论
abacus_plot