首页 > 解决方案 > 位置抖动的 geom_errorbar 问题

问题描述

我正在尝试使用 posistion_jitter 使我的观点不相互重叠。这适用于我的观点,但是当我将 position = position_jitter 应用于 geom_errorbar 时,误差线都被切断并且不在正确的位置。我怎样才能得到它,以便我的误差线与我的点正确对齐?

ggplot(summary_df.phase3_pt2_slope_vals_by_participant_ratio, aes(x = factor(participant_number, level = ratio_part_nums_sorted), y= ratio_error, group=participant_number, legend(size=legend_size))) +
  geom_point(aes(color = slope_change, shape = target_distance), size = 6, position = position_jitter(width = .2, height = .2)) +
  guides(color = guide_legend(reverse=TRUE)) + scale_color_manual(values = c(color.grey3, color.black)) + 
  xlab("Participant Number") + ylab("Mean Ratio Error") +
  theme(axis.title.x = element_text(size=axis.title_size), axis.title.y = element_text(size=axis.title_size), axis.text.x = element_text(size=axis.text_size), axis.text.y = element_text(size=axis.text_size), plot.title = element_text(size = plot.title_size, hjust = 0.5), legend.title = element_text(color="black", size = legend.title_size),legend.text = element_text(color="black", size = legend.text_size)) +
  scale_y_continuous(expand = expansion(mult = c(0, .1)), limits = c(.5,2)) +
  geom_errorbar(aes(ymin=ratio_error-std, ymax=ratio_error+std), width=.1, position = position_jitter(width = .2, height = .2)

在 geom_errorbar 上没有 position = position_jitter()

在 geom_errorbar 上使用 position = position_jitter()

标签: rggplot2

解决方案


推荐阅读