For an article on A/B testing that I am preparing, I asked my partner Dr. Nina Zumel if she could do me a favor and write some code to produce the diagrams. She prepared an excellent parameterized diagram generator. However being the author of the book Practical Data Science with R, she built it in
Rusing ggplot2. This would be great, except the A/B testing article is being developed in Python, as it targets programmers familiar with Python.
As the production of the diagrams is not part of the proposed article, I decided to use the
rpy2package to integrate the
Rdiagrams directly into the new worksheet. Alternatively, I could translate her code into Python using one of: Seaborn objects, plotnine, ggpy, or others. The large number of options is evidence of how influential Leland Wilkinson’s grammar of graphics (gg) is.
Click through to see how you can execute R code within the context of Python, similar to how you can use the reticulate package to execute Python code in the context of R.