displaying plots inside tabs in Rmarkdown
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- data-visualization
Research direction
Begin by reproducing the report with the attached plots.Rmd.zip and the two Python chunks using plotnine and seaborn. Trace how their output is handled when results="asis" is used inside R Markdown tabsets; done means each generated plot appears in its intended tab and the seaborn tabs are produced correctly.
Written by the indexing model from the issue text.
Description
If I try to display python plots inside tabs in Rmarkdown I get strange results:
Rmarkdown file attached
plots.Rmd.zip
## PLots
Trying to use plotnine, looks OK.
```{python}
import matplotlib
matplotlib.use('Agg')
from plotnine import ggplot, aes, geom_bar
from plotnine.data import mpg
p = ggplot(mpg) + geom_bar(aes(x="class"))
p
trying to use seaborn, looks OK.
import seaborn as sns
mpg.head()
sns.distplot(mpg.hwy);
Tabed Plotnine Plots {- .tabset .tabset-pills}
OK, with what we learned before, let's do then some plotnine plots inside tabs. Hmm, the tabs are produced,
but all the plots are acumulated on the final tab, the first two don't have anything. Actually you have to
click on the third tab if you want to show what is coming after.
conditions = ["class", "drv", "manufacturer"]
for condition in conditions:
print(f"### {condition} \n")
print('\n\n<!-- -->\n\n')
p = ggplot(mpg) + \
geom_bar(aes(x=condition))
p
print('\n\n<!-- -->\n\n')
print('\n\n<!-- -->\n\n')
Tabed Seaborn Plots {- .tabset .tabset-pills}
and with seaborn? Hmm strange results as well, this time no tabs.
import matplotlib.pyplot as plt
conditions = ["class", "drv", "manufacturer"]
for condition in conditions:
print(f"### {condition} \n")
print('\n\n<!-- -->\n\n')
plt.figure()
sns.countplot(x=condition, data=mpg)
print('\n\n<!-- -->\n\n')
- Dominant language
- R
- Stars
- 1.8k
- Forks
- 349
- Avg merge
- 5h 13m
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rstudio/reticulate
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
rstudio/reticulate#263 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
rstudio/reticulate#1927 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
rstudio/reticulate#1923 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
rstudio/reticulate#1907 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
rstudio/reticulate#1906 · 5 comments ·
All issues in rstudio/reticulate
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·