Hello everyone,
I am trying to figure out the resolution order of conflicting methods, particularly as it regards to the theme function in ggplot2 from R and Plots in Julia. Following up on the question here:
I’ve tried several of the suggested options. Only the first below works and the others which have been suggested do not. I am wondering why that is as when @rlibrary ggplot2
and theme
is called before loading the Plots
library, or @rimport ggplot2; ggplot2.theme
or R"library(ggplot2)"; R"theme"
is called, theme
appears to refer to the ggplot2 theme
function in the REPL. However, upon application I get the error that ERROR: syntax: invalid keyword argument name "axis.text"
which suggests that Plots.theme
is being invoked. There is also the suggestion not to load Plots at all, but that limits what I can do with the same script.
So my questions are:
- Why don’t some of the other methods work? Typing
theme
at the REPL seems to indicate that the ggplot2theme
function is preferentially referenced. - Is the first method really the only way to get this to work?
First method - only one that works
using RCall
using Plots
using DataFrames
using RDatasets
@rlibrary ggplot2
R"library(ggplot2)"
iris = dataset("datasets", "iris")
ggplot(data=iris)+
geom_point(mapping=aes(x=:PetalLength,y=:PetalWidth))+
R"theme(axis.text = element_text(size = 14))"
Second method - doesn’t work
using RCall
using Plots
using DataFrames
using RDatasets
@rlibrary ggplot2
R"library(ggplot2)"
iris = dataset("datasets", "iris")
ggplot(data=iris)+
geom_point(mapping=aes(x=:PetalLength,y=:PetalWidth))+
R"theme"(axis.text = element_text(size = 14))
Third method - doesn’t work
using RCall
using Plots
using DataFrames
using RDatasets
@rlibrary ggplot2
@rimport ggplot2
iris = dataset("datasets", "iris")
ggplot(data=iris)+
geom_point(mapping=aes(x=:PetalLength,y=:PetalWidth))+
ggplot2.theme(axis.text = element_text(size = 14))
Fourth method - doesn’t work
using RCall
@rlibrary ggplot2
theme
using Plots
using DataFrames
using RDatasets
iris = dataset("datasets", "iris")
ggplot(data=iris)+
geom_point(mapping=aes(x=:PetalLength,y=:PetalWidth))+
theme(axis.text = element_text(size = 14))
Fifth method - doesn’t work
using RCall
@rlibrary ggplot2
ggtheme = theme
using Plots
using DataFrames
using RDatasets
iris = dataset("datasets", "iris")
ggplot(data=iris)+
geom_point(mapping=aes(x=:PetalLength,y=:PetalWidth))+
ggtheme(axis.text = element_text(size = 14))