I'm working with Python and R Markdown with reticulate
.
It really works great but I have one problem:
A plot made with Python (seaborn) is not fully shown in my PDF and I don't know why.
This is how it looks on the PDF:
(Yes, I know, the heatmap doesn't make sense, it's only for demonstration purposes). As you can see there would be enough space for the row names and column names but you don't see them completely. Changing fig.width
and fig.height
does not really lead to better results. Do you have an idea what I can do that it is garanteed that the whole graphic is shown?
Here is my full code:
---
output:
pdf_document:
number_sections: true
lang: de
fontsize: 12pt
header-includes:
- \usepackage{float}
- \pagenumbering{gobble}
---
knitr::opts_chunk$set(
fig.height = 2,
fig.width = 5,
echo = TRUE,
fig.align = "center",
fig.pos = "H",
out.extra = "",
warning = FALSE,
message = FALSE)
library(reticulate)
import seaborn as sns
import pandas as pd
data = pd.read_csv("gapminder_full.csv")
ct = pd.crosstab(index = data["continent"],
columns = data["year"],
normalize = "index")
sns.heatmap(ct)
I'm not really sure if Python or seaborn is the problem. My impression is that only ggplot really works fine in R Markdown ... Probably you have a more general idea?