1

The following code yields a nice plot and all seems fine:

ggplot(data = ATPase_all_forplot, aes(x = AvTemp, y = AvAct)) +

    geom_errorbar(
    data = ATPase_all_forplot,
    aes(
        #x = ATPase_all_forplot$AvTemp,
        color = Rca,
        ymin = ATPase_all_forplot$AvAct - ATPase_all_forplot$SDEVAct ,
        ymax = ATPase_all_forplot$AvAct + ATPase_all_forplot$SDEVAct
    )) + geom_errorbarh(
    data = ATPase_all_forplot,
    aes(
        #y = ATPase_all_forplot$AvAct,
        color = Rca,
        xmin = ATPase_all_forplot$AvTemp - ATPase_all_forplot$SDEVTemp,
        xmax = ATPase_all_forplot$AvTemp + ATPase_all_forplot$SDEVTemp
    ),
    height = 0) + geom_smooth(
    data = ATPase_all_clean,
    aes(x = Temperature, y = Activity, color = Rca),
    se = TRUE,
    method = "gam",
    formula = y ~ s(x)) + geom_point(data = ATPase_all_forplot, aes(color = Rca, x = AvTemp, y = AvAct)) + facet_wrap(vars(Rca)) + labs(x = "Temperature (°C)", y = expression('ATPase activity (µmol mg' ^ "-1" * ' min' ^ "-1" * ')')) + scale_colour_manual(values = c("#0072B2", "#D55E00", "#E69F00", "#009E73")) + scale_y_continuous(breaks = c(0.0, 0.5, 1.0, 1.5, 2.0),limits = c(0.0, 2.0), sec.axis = dup_axis())

Some sample data from the dataset used in the ggplot() function:

 Rca AvTemp SDEVTemp AvAct SDEVAct
1   1β  15.40     0.24 0.257   0.094
2   1β  20.50     0.23 0.763   0.046
3   1β  25.13     0.16 1.041   0.103
4   1β  27.60     0.09 1.195   0.073
5   1β  29.90     0.27 1.333   0.120
6   1β  32.94     0.53 1.584   0.086
7   1β  35.07     0.24 1.641   0.095
8   1β  37.80     0.61 1.726   0.087
9   1β  40.06     0.18 1.646   0.092

However, when I export the plot as pdf and zoom in, I see these strange little lines extending from the error bars:

Error bars display issue

Any ideas what might be causing this? Cheers!

Gustaf
  • 11
  • 2
  • Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Nov 22 '18 at 20:19
  • I set geom_errorbar height = 0 and that fixed it. – Gustaf Nov 24 '18 at 17:18

0 Answers0