Editable graphics in PowerPoint from python: officer equivalent and rvg

I use the packs officerand rvgto obtain graphs of R in MS PowerPoint in the form of editable vector graphics. Playable example below.

I am looking for a way to implement an equivalent solution using Python, preferably using matplotlib. The most important part is not creating slides from the IDE, but the editable part of vector graphics, i.e. graphs should end in PowerPoint as grouped objects consisting of a series of simple PowerPoint geometries, such as lines, squares, and text fields.

Example R:

library(tidyverse)
library(officer)
library(rvg)

# Get some data and make a plot
ggp <- diamonds %>% 
  group_by(clarity) %>%
  summarise(price = mean(price)) %>%
  ggplot(aes(x = clarity, y = price, fill = clarity)) +
  geom_bar(stat = 'identity', colour = 'black')

# Create a new powerpoint document
doc <- read_pptx()
doc <- add_slide(doc, 'Title and Content', 'Office Theme')
# Add the plot 
doc <- ph_with_vg(doc, ggobj = ggp, type = 'body')  

# Write the document to a file
print(doc, target = 'plots.pptx')

The resulting diagram is fully editable:

enter image description here

+13
source share
1 answer

MS Office 2019 , svg , , . . " SVG Office" MS. , , .

, , , - powerpoint emf, . matplotlib . svg, inkscape --file "input.svg" --export-emf "output.emf" emf, powerpoint. , .

0
source

Source: https://habr.com/ru/post/1694037/


All Articles