R mschart 关闭线平滑
R mschart turn off line smoothing
我正在使用 mschart 版本 0.2.6 在 R 中为 powerpoint 绘制折线图。默认情况下,我得到平滑的线条,但不希望那样。我如何关闭它?
我在 github 上发现了以下功能请求,但它已关闭,我不确定它是如何解决的:
https://github.com/ardata-fr/mschart/issues/25
这是一个工作示例:
library(officer)
library(mschart)
dat<-data.frame(Year=c(rep("2010",3), rep("2011",3), rep("2012",3)),
Fruit=c(rep(c("Apples","Oranges","Pears"),3)),
Count = c(332,229,168,
223,189,225,
321,378,261), stringsAsFactors=F)
line_chart <- ms_linechart(data = dat, x = "Year",y = "Count", group="Fruit")
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(x = doc, value = c("Fruit"),
location = ph_location_type(type = "title") )
doc <- ph_with(doc, line_chart, location = ph_location_type(type="body"))
fileout <- "./Test.pptx"
print(doc, target = fileout)
这是它产生的结果。注意左下角勾选的平滑线选项:
将 ms_linechart
对象管道(或包装)到 chart_data_smooth()
函数中,并将 values
设置为 0。
library(officer)
library(mschart)
library(tidyverse)
line_chart <- ms_linechart(data = dat, x = "Year",y = "Count", group="Fruit") %>%
chart_data_smooth(values = 0) # Here is the code that sets lines to straight.
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(x = doc, value = c("Fruit"),
location = ph_location_type(type = "title") )
doc <- ph_with(doc, line_chart, location = ph_location_type(type="body"))
fileout <- "./Test2.pptx"
print(doc, target = fileout)
我正在使用 mschart 版本 0.2.6 在 R 中为 powerpoint 绘制折线图。默认情况下,我得到平滑的线条,但不希望那样。我如何关闭它?
我在 github 上发现了以下功能请求,但它已关闭,我不确定它是如何解决的: https://github.com/ardata-fr/mschart/issues/25
这是一个工作示例:
library(officer)
library(mschart)
dat<-data.frame(Year=c(rep("2010",3), rep("2011",3), rep("2012",3)),
Fruit=c(rep(c("Apples","Oranges","Pears"),3)),
Count = c(332,229,168,
223,189,225,
321,378,261), stringsAsFactors=F)
line_chart <- ms_linechart(data = dat, x = "Year",y = "Count", group="Fruit")
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(x = doc, value = c("Fruit"),
location = ph_location_type(type = "title") )
doc <- ph_with(doc, line_chart, location = ph_location_type(type="body"))
fileout <- "./Test.pptx"
print(doc, target = fileout)
这是它产生的结果。注意左下角勾选的平滑线选项:
将 ms_linechart
对象管道(或包装)到 chart_data_smooth()
函数中,并将 values
设置为 0。
library(officer)
library(mschart)
library(tidyverse)
line_chart <- ms_linechart(data = dat, x = "Year",y = "Count", group="Fruit") %>%
chart_data_smooth(values = 0) # Here is the code that sets lines to straight.
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(x = doc, value = c("Fruit"),
location = ph_location_type(type = "title") )
doc <- ph_with(doc, line_chart, location = ph_location_type(type="body"))
fileout <- "./Test2.pptx"
print(doc, target = fileout)