ex:当我有折线图时,我想显示的颜色是(“绿色”代表线a,“紫色”代表线b),在R mschart中可行吗? 图书馆(官员) 图书馆(Mschart) 库(dplyr)
data <- data.frame(Name=c("a","a","a","a","b","b","b","b"),
wave_id=c("2017Q1","2017Q2","2017Q3","2017Q4","2017Q1","2017Q2","2017Q3","2017Q4"),
pct=c(0.68,0.71,0.70,0.72,0.57,0.57,0.57,0.58))
data1 <- data%>%
ms_linechart(x="wave_id",y="pct",group="Name")%>%
chart_labels(title=NULL,xlab=" ",ylab=" ")%>%
chart_ax_y(limit_min = 0.4,limit=0.8,
num_fmt='0%%',major_tick_mark="none",minor_tick_mark="none")
data1_theme<- mschart_theme(
axis_title = fp_text(font.size=1),
legend_position = "r",
grid_major_line=fp_border(width=))
pptsdata1 <- set_theme(data1, data1_theme)
doc <- read_pptx()
doc <-doc%>%
add_slide(layout = "Title and Content", master = "Office Theme")%>%
ph_with_chart_at(chart=pptsdata1, left=1, top=1, height=3, width=8)
print(doc, target = "my_plot.pptx")
答案 0 :(得分:0)
您可以在创建ms_linechart时使用以下内容:
data1 <- data%>%
ms_linechart(x="wave_id",y="pct",group="Name")%>%
chart_labels(title=NULL,xlab=" ",ylab=" ")%>%
chart_data_stroke(my_colors) %>%
chart_ax_y(limit_min = 0.4,limit=0.8,
num_fmt='0%%',major_tick_mark="none",minor_tick_mark="none")
其中my_colors
是指定颜色的列表,例如
my_colors <- list(
a = "green",
b = "purple"
)
a和b是这些行的名称