rmschartofficer

removing markers from linechart in mschart


I am using officeRand mscharts to create powerpoints from R. I have ran into a problem where I dont know how to remove the markers from the line charts. The mschart package says that from version 0.3.1 you are able to have line charts with or without markers but I can't figure out how. Below is an example of a line chart which includes markers.

library(tidyverse)
library(mschart)

mtcars %>% 
  as_tibble(rownames = "car") %>% 
  mschart::ms_linechart(x = "car", y="mpg") %>% 
  mschart::chart_theme(legend_position = "t",
                       axis_text_y = fp_text(font.size = 8),
                       axis_text_x = fp_text(font.size = 6)
  ) %>% 
  print(preview=TRUE)


Solution

  • You could use chart_settings where you can specify the style with "line", so it will only plot a line without the markers. Here a reproducible example:

    library(tidyverse)
    library(mschart)
    library(officer)
    
    mtcars %>% 
      as_tibble(rownames = "car") %>% 
      mschart::ms_linechart(x = "car", y="mpg", group = NULL) %>% 
      mschart::chart_theme(legend_position = "t",
                           axis_text_y = fp_text(font.size = 8),
                           axis_text_x = fp_text(font.size = 6)
      ) %>% 
      mschart::chart_settings(style = "line") %>%
      print(preview=TRUE)
    

    Output:

    enter image description here