Description of the "self object"

40 views
Skip to first unread message

Henrik

unread,
Sep 27, 2016, 2:52:42 AM9/27/16
to ggplot2
In the source code of ggplot, it is often refered to a "self object" and different slots therein. For example, in scale-.r we find, among others, self$get_limits(), self$breaks, self$break_positions(). "self" is mentioned in  ?ggroto, but I fail to find information about the slots the way they are used in the ggplot code.

Can someone please point me to relevant documentation of "self" and its different slots.  

Brian

unread,
Sep 27, 2016, 5:25:34 AM9/27/16
to Henrik, ggplot2
Hi Henrik,
As you probably know you are looking at reference class R code:

http://adv-r.had.co.nz/R5.html

I remember Hadley mentioning a new object orientation class used for the last (2.0?) ggplot2 release. If true and undocumented, I guess the "self" refers to containing object (Class) - as it does in python. Otherwise this is inherent to the reference class.

HTH,
Brian

Henrik

unread,
Sep 29, 2016, 5:31:28 AM9/29/16
to ggplot2, henri...@gmail.com
Hi Brian!

Thank you for your rapid reply. My first attempt to find the slots used in self was to look at str(myplot) and ggplot_build(myplot), without success. They must be hidden deeper down (or further sideways...) than I have dug so far. Or I might have misunderstood the R5 concept entirely...

Cheers

Ista Zahn

unread,
Sep 29, 2016, 7:20:35 AM9/29/16
to Henrik, ggplot2

There is some documentation at http://docs.ggplot2.org/current/vignettes/extending-ggplot2.html, but presumably self is used to refer to an object from inside one of its methods.

Best,
Ista


--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian

unread,
Sep 29, 2016, 7:47:58 AM9/29/16
to Henrik, Ista Zahn, ggplot2
Hi Henrik,

who knows where you are at in programming knowledge and what you exactly
want to do. I have a feeling that Ista's tip is the right one - you want
to extend ggplot2. If you are familiar with OO-languages, e.g. python,
then R5 is a breeze. Otherwise, it can be intimidating at first. I
suggest starting with some documentation. Then digging/tunneling won't
be confusing.

Slots belong to S4. In R5, "fields are the equivalent of slots in S4."

Good luck,
Brian


On 09/29/2016 01:20 PM, Ista Zahn wrote:
> There is some documentation at
> http://docs.ggplot2.org/current/vignettes/extending-ggplot2.html, but
> presumably self is used to refer to an object from inside one of its
> methods.
>
> Best,
> Ista
>
>
> On Sep 29, 2016 5:31 AM, "Henrik" <henri...@gmail.com
> <mailto:henri...@gmail.com>> wrote:
>
> Hi Brian!
>
> Thank you for your rapid reply. My first attempt to find the slots
> used in self was to look at str(myplot) and ggplot_build(myplot),
> without success. They must be hidden deeper down (or further
> sideways...) than I have dug so far. Or I might have misunderstood
> the R5 concept entirely...
>
> Cheers
>
>
> On Tuesday, September 27, 2016 at 11:25:34 AM UTC+2, zenlines wrote:
>
> Hi Henrik,
> As you probably know you are looking at reference class R code:
>
> http://adv-r.had.co.nz/R5.html
>
> I remember Hadley mentioning a new object orientation class used
> for the last (2.0?) ggplot2 release. If true and undocumented, I
> guess the "self" refers to containing object (Class) - as it
> does in python. Otherwise this is inherent to the reference class.
>
> HTH,
> Brian
>
>
> El 27 de septiembre de 2016 8:52:41 AM GMT+02:00, Henrik
> <henri...@gmail.com> escribió:
>
> In the source code of ggplot, it is often refered to a "self
> object" and different slots therein. For example,
> in scale-.r
> <https://github.com/hadley/ggplot2/blob/master/R/scale-.r> we find,
> among others, self$get_limits(), self$breaks,
> self$break_positions(). "self" is mentioned in ?ggroto, but
> I fail to find information about the slots the way they are
> used in the ggplot code.
>
> Can someone please point me to relevant documentation of
> "self" and its different slots.
>
> --
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
> <https://github.com/hadley/devtools/wiki/Reproducibility>
>
> To post: email ggp...@googlegroups.com
> <mailto:ggp...@googlegroups.com>
> To unsubscribe: email ggplot2+u...@googlegroups.com
> <mailto:ggplot2%2Bunsu...@googlegroups.com>
> More options: http://groups.google.com/group/ggplot2
> <http://groups.google.com/group/ggplot2>
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to ggplot2+u...@googlegroups.com
> <mailto:ggplot2+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ggplot2+u...@googlegroups.com
> <mailto:ggplot2+u...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages