IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

Check the ggpubr package? #4758

Open rdstern opened 6 years ago

rdstern commented 6 years ago

The ggpubr package claims to be a way of using ggplot to easily get publication quality graphics in R. It seems to be a sort of R command equivalent of what we are trying to do through dialogues.

How does this relate to our specific graph dialogues and also perhaps particularly to our special graphs, such as the PICSA rainfall graph, which is based on a line plot? Combining their ggline with their ggpar has most of the options we need for our PICSA line plots?

I suggest this is important enough that we should quickly evaluate its possible role in R-Instat.

Another package that is installed with ggpubr is ggsci. This is a package devoted to colour palettes - something we have yet to add to our graphics system.

maxwellfundi commented 6 years ago

@rdstern I have now had a chance to look at bits of this package this morning and majorly works in more or less the same way as ggplot. I see some of the things in this package example the vertical X tick markers easier to as we just pass in the parameters to main function. For example if in our Picsa dialogs, we could use this very easily, i think.

Adding layers too is easy, if they are on the same data frame and using the same aesthetics by passing in add = c("jitter", "violin", ...)

I am not sure how this would interact with our general system as most of the parameters are passed into the main specificggplot function. If we were to implement this in our plots then we would need to do more work of changing a bit of how our system works

maxwellfundi commented 6 years ago

I have also found out that, we can use this package with our plots dialogs and work in similar way with our system. Facets also work in the same way as we have currently as well as other options in our general plots sub dialog.

If I was to do this plot using the ggpubr functions

ggplot2::ggplot(data=survey, mapping=ggplot2::aes(y=Yield, fill=Village., x=Variety.)) + ggplot2::geom_boxplot(outlier.colour="red", notch=TRUE, outlier.shape=24) + ggplot2::facet_grid(facets=Village. ~ Variety., space="fixed") + ggplot2::labs(title="Tittle", subtitle="Sub Title", caption="Caption") + ggplot2::coord_flip()+ ggplot2::geom_jitter()

I could simply have

ggboxplot(survey, y="Yield", fill="Village.", x="Variety.", outlier.colour="red", notch = FALSE, outlier.shape= 24)+ facet_grid(facets=Village. ~ Variety., space="fixed")+ ggplot2::labs(title="Tittle", subtitle="Sub Title", caption="Caption") + ggplot2::coord_flip()+ ggplot2::geom_jitter()

@dannyparsons @volloholic I think our current system is good, am not having a strong feeling that we need to change to this, but some of the dialogs like PICSA graphs can easily use this. What do are your thoughts?

dannyparsons commented 6 years ago

The graphs do look very nice. The package seems to do 3 main things:

  1. better defaults
  2. simpler syntax/easy ways to change common options

I don't think we want to have a simpler syntax for ggplot in R-Instat because it doesn't matter to the users - unless they want to learn R in which case ggplot code is more standard, and there will likely be some, maybe very specific things not possible through the simplified syntax. It would also mean rewritting most of our graphics dialog "system". But we do want easy ways for our users to change common options. We can also have whatever defaults we like in R-Instat so we should learning from this package about what better defaults we might have.

I can't quite see where we would use the package directly, maybe in the special graphs like PICSA, but then this would not link in to our graphics system sub dialogs, and I guess as soon as this is used in one place people will ask why all dialogs don't come out this nicely.

I do think we should look into the package more to:

  1. understand what options they have made easy to change and how we should do this in R-Instat e.g. common theme options
  2. what defaults for themes and different geoms they are using to get these nice graphs and whether we should have similar defaults for our specific dialogs.
rdstern commented 6 years ago

Ok, I agree. If we use the package for part of the PICSA graphs dialogue (say), then we c an't mix that with our standard options. So we have to stick with our system. But, in addition to the 2 points Danny makes, I suggest there may also be one or two commands in their package that could be useful for us? And we should also check them out.

They include as_ggplot and ggarrange.

One use I could see for ggarrange is that it can arrange plots over multiple "pages" and we need this for our Climatic > Check Data > Display Daily > Graph. Just as our tables go over many pages we can't usually display the graphs in a single page.

maxwellfundi commented 6 years ago

@dannyparsons Thanks you for your comment, I will then push forward the PICSA dialog without using this package and if need be to change in future then we will.

dannyparsons commented 6 years ago

Those two functions look useful and could be incorporated in our Use Graph and Combine Graph dialogs.