deeptime icon indicating copy to clipboard operation
deeptime copied to clipboard

`pos` order is inconsistent for different sides

Open willgearty opened this issue 2 years ago • 2 comments

No one has complained about this (yet), but it looks like the behavior of the pos argument is different for whichever side you are specifying.

For example, for the bottom axis, the scales are added from the plot outwards:

ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 100))) +
    scale_x_reverse() +
    coord_geo(
        xlim = c(100, 0), ylim = c(0, 8), pos = as.list(rep("bottom", 3)),
        dat = list("stages", "epochs", "periods"),
        height = list(unit(4, "lines"), unit(4, "lines"), unit(2, "line")),
        rot = list(90, 90, 0), size = list(2.5, 2.5, 5), abbrv = FALSE
    ) +
    theme_classic()

image

But for the top axis, the scales are added from the outside inwards:

ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 100))) +
    scale_x_reverse() +
    coord_geo(
        xlim = c(100, 0), ylim = c(0, 8), pos = as.list(rep("top", 3)),
        dat = list("stages", "epochs", "periods"),
        height = list(unit(4, "lines"), unit(4, "lines"), unit(2, "line")),
        rot = list(90, 90, 0), size = list(2.5, 2.5, 5), abbrv = FALSE
    ) +
    theme_classic()

image

The same is true for left (inside outwards) and right (outside inwards) scales.

willgearty avatar Apr 24 '23 13:04 willgearty

On the one hand, at least their relative positions to one another are the same for top/bottom and for left/right, so maybe this is fine? On the other hand, the behavior of palaeoverse::axis_geo is to always add scales outwards which seems like a good behavior to me.

It shouldn't be too hard to mimic this behavior by just reversing the order of the grobs for the left and top options in this section: https://github.com/willgearty/deeptime/blob/4bf2fdfb19d25b1218531b9add7243eb3d9c50e3/R/coord_geo.R#L232-L264

willgearty avatar Apr 24 '23 13:04 willgearty