Skip to content
7cm-diameter edited this page Aug 23, 2021 · 1 revision

grgr

grgr is a library for using ggplot2 from python.

grgr can create figures in python using grammar similar to ggplot2. python does not create the figure itself, but generates a code that can be executed in R, and executes it in R to create the figure. In other words, grgr is an interface from python to R's ggplot2. Therefore, this library directly depends on R and ggplot2.

Quickstart

You can install grgr through pip by running pip install grgr. In order to use grgr, you need to have R and ggplot2 installed. Please make sure that these are installed beforehand. Once the installation is complete, you can draw a figure in python with the grammer same as ggplot2.

After installation, try running the following code.

import grgr.ggplot2 as g
import numpy as np
from pandas import DataFrame

x = np.arange(0, 10, 0.1)
y = np.random.normal(10, 2, 100)

df = DataFrame({"x": x, "y": y})

g.ggplot(df) + \
    g.geom_point(mapping=g.aes("x", "y"))

If you see a scatter plot, your dependencies should be fine. If it returns an error, please check the dependencies again. If the problem persists, please report it to Issiue.

Clone this wiki locally