简体   繁体   中英

How to Adjust Font Size of a ggplot in inkscape?

When I export ggplots from R (with ggsave in svg) to modify them in inkscape, I run into the following problem:

I use the text tool to select some text (axis labels for example). If I want to increase font size in the drop down menu, inkscape only increases the height of the text, width stays the same. I am left with text with the wrong aspect ratio.

This must be due to some type conversion (text to object for example) that is done at some point (ggplot, ggsave or inkscape). Until now I have been unable to figure out how to solve this. So far, I have reverted to deleting the existing text and creating new text in inkscape (adjusting font size works totally normally then)

Code to create input for Inkscape:

tdf <- data.frame()

tpl <- ggplot(tdf) + xlab("testtext")

ggsave(filename="tpl.svg",plot=tpl,height=5,width=8,device="svg")

It appears svglite introduces a textLength parameter which hard-codes the width. Interstingly, Illustrator seems to not care about this when editing the file, but Inkscape does.

You could try another device, svg may not be a great choice as it appears to split words into individual letters, but gridSVG::gridsvg seems to works. Or use a pdf device, which Inkscape can also import.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM