I need to draw specific diagrams in R. In Python, I solve the problem by creating a 2480x3508 px canvas (an A4 sheet at 300 DPI) using the pillow package. I can then draw lines, text, and simple geometries using the pillow package. An example is provided in the code below. from PIL import Image, ImageDraw, ImageFont import os fontsFolder = r'C:\Windows\Fonts' # adjust to your OS rys = Image.new('RGBA', (2480, 3508), 'white') # A4 sheet rysunek = ImageDraw.Draw(rys) rysunek.line([(100, 100), (200, 100)], fill='black') rysunek.line([(100, 200), (300, 200)], fill='black', width=2) rysunek.line([(100, 300), (400, 300)], fill='black', width=3) rysunek.line([(100, 400), (500, 400)], fill='black', width=4) rysunek.polygon(((100, 500), (115, 500), (100, 515), (100, 500)), fill = "red") testFont = ImageFont.truetype(os.path.join(fontsFolder, 'CYKLOP-REGULAR.TTF'), 32) # Insert any file with a true-type font on your computer here. rysunek.text((100, 600), 'Hello world', fill='darkgreen', font=testFont) rys.save(r'drawing.png') Sample result in the form of a drawing: Of course, the diagram is more complex, but if I can draw the above elements at the appropriate size, I can easily write a functions and loops to generate the entire diagram. I'm interested in translating the above code into R, as I perform all my data analysis and processing in R, and it will be easier for me to generate finished diagrams from that language (without using Python). Maintaining accurate element dimensions (perhaps in pixels or mm, cm etc.) and using true-type fonts are crucial to me. Continue reading...