Skip to content

trans, reverse, and negatives #287

@SimonDedman

Description

@SimonDedman

With marine data, one typically wants to present depth on the Y-axis, starting with 0 at the top and with values of greater depth increasing as you do down the axis, as a visual analogue to descending deeper into the ocean:
image
A simple, albeit a little hacky, way of achieving this is:
df$depth <- -df$depth
Then scaling to one's preference, noting the negative:
scale_y_continuous(breaks = seq(-600, 0, by = 100), limits = c(-600, 0)) +

For various biological & oceanographic reasons, many marine species spend a disproportionate amount of time near the surface, such that there's a heterogeneous distribution of importance and data-ink in the top bit, and a lot of wasted space below.
image

Subsequently it would be nice to transform the scale and keep the reverse orientation, but, as I understand it, this isn't natively possible with the current setup:

  1. Keep original depth data as positive continuous. Can use rescaling transforms (log1p, sqrt) (trans = "log1p") OR reverse (trans = "reverse"), but not both.

  2. Pre-convert depth data to negative. No need to use reverse transform, but can't use (some/all) rescaling transforms because they don't work on negative values (even though this says sqrt does due to a bug, it doesn't for me)

While I presume I could sort this with a custom trans_new, I suspect based on various StackOverflow posts that this is a common enough issue, in various guises, to warrant inclusion as a feature request.

Proposed solutions:

A. Add reverse = FALSE as a default parameter to all transforms, such that one can set this to true to rescale their cake and reverse it too (and thus remove reverse_trans),

B. Allow transform functions to operate on negatives by converting them to positives then converting the results back. This could be an optional parameter e.g. allowNegative.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions