Skip to content

Axis labeller function (xaxl / yaxl?) #362

@grantmcdermott

Description

@grantmcdermott

[...] I think the only outstanding question is the one that your originally posed here:

Open question: What to do about corresponding axis? Instead having both positive and negative labels, both parts of the axis are often displayed with positive labels. Is this something we might also need elsewhere?

I've sort of been thinking about this axis labeling issue in general. ggplot2 has nice integration with the scales package for customized labeling of axes by passing an appropriate function, e,g. percent labels. It would be cool if we could support this kind of functionality too in tinyplot and I think the logical place to implement it is in tinyAxis.R.

In the present case, for example, you could add the following abs() transformation just before do.call() call here.

do.call("Axis", args)

args$at = axTicks(args$side)
args$labels = abs(args$at)

Originally posted by @grantmcdermott in #361 (comment)


Addendum: Thinking about this some more, an implementation option might be to introduce two new xaxl and yaxl arguments (which would complement the existing xaxt, xaxs, etc. axis customizers). These would accept a function that would transform the label ticks... with some canned routines available as strings. These functions would then get passed to tinyAxis.R as in the above abs example.

Prospective syntax:

tinyplot(..., xaxl = "percent", yaxl = "dollar")
tinyplot(..., xaxl = abs)
tinyplot(..., xaxl = \(x) bquote(10^.(log10(x))))
# etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions