Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

export::graph2office moves labels around

$
0
0

I have made plots in R (RStudio) with ggplot2. When I export them via export::graph2office, the labels are moved around. However, this only happens when I specify the font for the labels.

library (ggplot2)
library (export)    


plot_data <- data.frame (a = runif (1:20), b = seq (1:20))

x11 (width =  3, height = 3)

ggplot (data = plot_data, mapping = aes (x = a, y = b)) +
    geom_point () +
    labs (x = "my x-label", y = "my y-label") +
    theme (panel.background = element_blank(),
           panel.border = element_rect (fill = NA, size = 0.7),
               axis.ticks = element_line (color = "black", lineend = "round"),
               axis.ticks.length = unit (2, "mm"),
               axis.text = element_text (color = "black"),
               plot.margin = unit(rep (0, 4), "cm"),
                      text = element_text (size=18,  
                                family="ChantillyLH", 
                                color = "black")
               )

graph2office (file = "my_graph", type = "DOC")

Here, you can see the graph in R (to the right) and the exported graph in word (to the left): enter image description here

The undesired behaviour is more obvious for the y-label in this example, but also the x-label is moved a bit. I wonder if there is a way to fix this.

The same happens when I specify another font family, for example family="Comic Sans MS":

enter image description here

EDIT: it even happens when no textcommand is given: enter image description here


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>