holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.5k stars 492 forks source link

Add RGGPlot reference notebook or gallery example #3375

Open MarcSkovMadsen opened 2 years ago

MarcSkovMadsen commented 2 years ago

As a part of adding docstrings to Panes I discovered the RGGPlot pane.

image

I was not aware of its existence and guess other users would be in the same situation.

Please add a reference notebook or gallery example.

maximlt commented 1 year ago

I just tried this Pane, not publishing a new reference example as we are reworking this part and it may change, but I'll record in this issue some instructions to create an example with this pane.

from rpy2.robjects.vectors import IntVector
from rpy2.robjects.packages import importr, data
from rpy2 import robjects
import rpy2.robjects.lib.ggplot2 as ggplot2

base = importr('base')
stats = importr('stats')
datasets = importr('datasets')

mtcars = data(datasets).fetch('mtcars')['mtcars']

rnorm = stats.rnorm
dataf_rnorm = robjects.DataFrame({'value': rnorm(300, mean=0) + rnorm(100, mean=3),
                                  'other_value': rnorm(300, mean=0) + rnorm(100, mean=3),
                                  'mean': IntVector([0, ]*300 + [3, ] * 100)})

gp = ggplot2.ggplot(mtcars)

pp = gp + \
     ggplot2.aes_string(x='wt', y='mpg') + \
     ggplot2.geom_point()

import panel as pn

pn.extension()

pn.pane.RGGPlot(pp)

image