鍍金池/ 問答/數(shù)據(jù)分析&挖掘  數(shù)據(jù)庫(kù)  網(wǎng)絡(luò)安全/ 關(guān)于ggplot2主題設(shè)置的問題

關(guān)于ggplot2主題設(shè)置的問題

手抄《R語(yǔ)言實(shí)戰(zhàn)》中的主題設(shè)置代碼,不知道為什么老是報(bào)錯(cuò),代碼如下:

library(ggplot2)
data(Salaries, package='car')

mytheme<-(plot.title=element_text(face='bold.italic',size=14,color='brown',hjust=0.5),
          axis.title=element_text(face='bold.italic',size='10',color='brown'),
          axis.text=element_text(face='bold.italic',size='9',color='darkblue'),
          panel.background=element_rect(fill='white',color='darkblue'),
          panel.grid.major.y=elemnt_line(color='grey',linetype=1),
          panel.grid.minor.y=element_line(color='grey', linetype=2),
          panel.grid.minor.x=element_blank())



ggplot(Salaries, aes(x=rank,y=salary,fill=sex)) + 
  geom_boxplot() +
  labs(title='Salary by Rank and Sex',x='RANK',y='Salary') +
  mytheme

報(bào)錯(cuò)信息如下:

> source('~/.active-rstudio-document')
Error in source("~/.active-rstudio-document") : 
  ~/.active-rstudio-document:18:86: unexpected ','
17: 
18: mytheme<-(plot.title=element_text(face='bold.italic',size=14,color='brown',hjust=0.5),
                                                                                         ^

逗號(hào)也沒有錯(cuò)啊,是英文的,請(qǐng)問到底是哪里錯(cuò)了,謝謝!

回答
編輯回答
鐧簞噯

漏了theme(),犯了個(gè)2b錯(cuò)誤。。。

2017年8月1日 19:13