Hi everyone,
I have been working on small ggplot extension to speed-up some common analysis I need to run repeatedly. I have completed the code for my custom geom, but I was wondering if I can also set a default axis label. Do you guys know a solution?
@taras has a good point. This would be an excellent question for Stack Overflow if you could add some reproducible code to illustrate precisely what you are looking for.
The benefit of posting specific code questions at Stack Overflow is that more people are likely to benefit from the answers when you post there.
I realize this is tilting into the realm of #meta, but might be helpful to have a guide/post (maybe R Views or RStudio Blog?) on which kinds of questions might fit SO, etc. That, or just a visible link to rOpenSci's SO/reprex community call
@andremrsantos What sort of axis did you have in mind? I think that, with the way ggplot2 works, the axis type is going to be determined by the type of data going in, rather than by the geom (or geoms) you're plotting. In other words, they're kind of independent. So you could include a custom scale in your extension package, but I'm not sure if you can set a particular scale to be used whenever you use the geom (unless there's some way to specify what types of data a geom can ingest and therefore what scales are available to it). Does that make sense?
That said, @mara's idea of defining a function that returns multiple ggplot2 element is a good one! So you have a geom defined, a scale defined, and then a function that returns them both in a list and can basically be used in place of the geom.
It isn't clear to me that this isn't an appropriate post for here.
It would certainly fall into the realm of questions asked on the ggplot mailing list, and that group were specifically asked to migrate to here. I assumed to carry on providing help to one another, but maybe I've got that wrong.
Hi @rensa,
I'm trying to define a stat that given a sample of p-values, it generates a qqplot for diagnostics (see code bellow). I was able to change the axis label to expected and observed using the code, but I was looking to define it as "Expected log[10] P" and "Observed log[10] P" to reduce my later presentation work.
P.S. I've also made a custom geom (which I was referencing) that plots not only the dots, but also a regression line and confidence interval lines.
P.S.S Its a fringe use case, but I need it quite frequently