Can't find the length mismatch that R errors on

Dueling purposes are at play. The only line that will connect the points for all the stimuli together will be the one that looks like my first attempt to parallel park. Because as CR increases, Score increases at different rates for different stimuli? It is possible to show separate curves, which you would probably want to color key in the same way. My aesthetic sense (but not my call) is that points, colors, and the crossing trend and error bar lines (vertical and the crossbar terminators) is a candidate for faceting by stimulus. But that's just me and the peep you hang with may have the Way and you gotto go with the flow?

1 Like

This figure shows that Score varied randomly as CR increased, regardless of the target's color. That's because performance was at asymptote already at CR = 3. The error bars (which represent the critical difference per Fisher's LSD test) all overlap, meaning none of the pairwise differences are reliable statistically. Graphing them as I have is the clearest way to show these things.

We're fine with a (thin) connecting line that zigzags up and down, if I can discover how to draw it.

Your CR variable is already arranged from lowest to highest. This has no grouping for either error bars or lines, just for points:

ColorN = as.factor(c(1:11, 1:11, 1:11, 1:11))

ggplot(CRatio, aes(x = CR, y = Mean)) +
  geom_errorbar(aes(ymin = Mean - FLSD, ymax = Mean + FLSD), 
                width = 0.12, 
                linewidth = 0.25) +
  geom_line(linewidth = 1) +
  geom_point(aes(fill = ColorN), 
             shape = 21, 
             color = "black", 
             size = 5,
             show.legend = FALSE) +
  scale_fill_manual(values = c("1" = "#07CDED", "2" = "#5E8DF6", "3" = "#C5955B", "4" = "#B3B3B3", 
                               "5" = "#23E162", "6" = "#D822FF", "7" = "#FE930D", "8" = "#F684D8", 
                               "9" = "#FF1320", "10" = "#FFFFFF", "11" = "#DFF334")) +
  xlab("Contrast Ratio") +
  ylab("Score")
2 Likes

Success!

I'm still murky about when parameters belong in an aes and when they don't. Trying to discover the right combo is still largely a matter of trying every permutation I can think of until it works. The one thing that seems clear is that parameters spec'd in the 1st aes are global.

Thank you and everyone else for your patient assistance. I'll suggest dispensing with the connecting lines which, I agree, clutter the image and add no useful information. At least I know how to remove them! :smiley:

You beat me to it, but here's what I did just to compare notes. The global nature of the first aes can be changed with a mapping argument in a subsequent geom. So, I plotted geom_line first and then reset.

library(ggplot2)

CRatio <- structure(list(
  CR = c(
    2.998333, 3.108333, 3.18, 3.3, 3.361667,
    3.491667, 3.543333, 3.566667, 3.683333, 3.8, 4.033333, 4.116667,
    4.266667, 4.4, 4.683333, 4.758333, 4.85, 4.966667, 5.1, 5.125,
    5.2, 5.441667, 5.5, 5.55, 5.583333, 5.783333, 5.875, 5.9, 6,
    6.041667, 6.25, 6.416667, 6.5, 6.833333, 6.958333, 7.416667,
    8.333333, 9, 9.666667, 10.166667, 10.333333, 11, 11.833333, 12.666667
  ), N = c(
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L
  ),
  Mean = c(
    98.51484, 98.6915, 97.19956, 99.62121, 99.0728,
    99.03826, 98.46969, 97.87017, 99.40248, 99.08854, 96.34522,
    98.07239, 99.84888, 98.82275, 99.0842, 97.5418, 97.5108,
    97.98772, 99.08951, 99.16667, 97.9485, 97.57339, 97.91835,
    97.10219, 99, 99.12898, 98.2, 97.71143, 95.74095, 97.60755,
    99.06346, 98.13807, 96.74669, 99.10304, 98.87785, 99.02886,
    98.48485, 97.90073, 98.40473, 99.47872, 98.89801, 99.03092,
    98.10606, 99.16574
  ), SD = c(
    2.2059607, 2.5807032, 3.6635529,
    1.0713739, 1.718406, 2.2359232, 1.8257819, 4.3723549, 1.2322768,
    2.3357171, 6.4676819, 4.0054505, 0.2799125, 2.2450952, 2.0983847,
    3.7142882, 2.7521562, 1.6890816, 2.5752654, 2.3570226, 3.3604801,
    4.5016953, 3.4528359, 4.040724, 2.8284271, 1.4625682, 2.6629516,
    3.6613992, 6.2436828, 6.5195377, 2.4092048, 5.2663441, 6.4315022,
    1.4920179, 1.5580408, 1.4782993, 4.2854956, 3.7484537, 1.7253653,
    1.2501322, 1.4817396, 1.8017662, 5.3568696, 1.5458937
  ), FLSD = c(
    1.429252,
    1.429252, 1.429252, 1.429252, 1.429252, 1.429252, 1.429252,
    1.429252, 1.429252, 1.429252, 1.429252, 1.429252, 1.429252,
    1.429252, 1.429252, 1.429252, 1.429252, 1.429252, 1.429252,
    1.429252, 1.429252, 1.429252, 1.429252, 1.429252, 1.429252,
    1.429252, 1.429252, 1.429252, 1.429252, 1.429252, 1.429252,
    1.429252, 1.429252, 1.429252, 1.429252, 1.429252, 1.429252,
    1.429252, 1.429252, 1.429252, 1.429252, 1.429252, 1.429252,
    1.429252
  )
), class = "data.frame", row.names = c(NA, -44L))

ColorN <- as.factor(c(1:11, 1:11, 1:11, 1:11))

ggplot(CRatio, aes(x = CR, y = Mean)) + #, fill = ColorN, group = CR)) +
  geom_errorbar(show.legend = FALSE, aes(ymin = Mean - FLSD, 
                                         ymax = Mean + FLSD), 
                                         width = 0.06, 
                                         color = "#545454",
                                         linewidth = 0.3,
                                         linetype = 2) +
  geom_line(color = "#545454", 
            linewidth = 0.3) +
  geom_point(inherit.aes = FALSE,
            mapping = aes(x = CR, y = Mean),
            data = CRatio,
            fill = ColorN, 
            #group = CR,
            show.legend = FALSE, 
            shape = 21, 
            color = "black", 
            size = 4) +
  scale_fill_manual(values = c(
    "1" = "#07CDED", "2" = "#5E8DF6", "3" = "#C5955B", "4" = "#B3B3B3",
    "5" = "#23E162", "6" = "#D822FF", "7" = "#FE930D", "8" = "#F684D8",
    "9" = "#FF1320", "10" = "#FFFFFF", "11" = "#DFF334"
  )) +
  xlab("Contrast Ratio") +
  ylab("Score") +
  theme_minimal()

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.