Defining ggplot scales for custom S3 classes

Does anyone know where I can find documentation on creating custom ggplot2 scales for S3 classes? I am working on a package that contains a class for year-quarter/month/week dates and I'd like them to show up nicely by default.

I found an old gist that does something similar for the zoo package, but that one is 6 years old and contains some guessing judging from the comments. I was wondering if there is some official documentation somewhere.

There is a great vignette on how to extend ggplot2
https://ggplot2.tidyverse.org/articles/extending-ggplot2.html
I don't know if it covers all you are looking for but it could be a start if you don't know about it.

I've seen that, there are some small code examples on scales, but i was hoping for something more detailed

1 Like

It's possible you've already seen this, too, but there is a section in the scales function reference on Creating your own scales and mutable ranges.

1 Like

Hmm thanks that also seems helpfull.. ill see if i can manage to hack something together :slight_smile: