惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
MongoDB | Blog
MongoDB | Blog
美团技术团队
H
Help Net Security
G
Google Developers Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
J
Java Code Geeks
M
MIT News - Artificial intelligence
腾讯CDC
IT之家
IT之家
Vercel News
Vercel News
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
Last Week in AI
Last Week in AI
I
InfoQ
博客园 - 司徒正美
A
About on SuperTechFans

Home on Jinji

日本 死亡与迷茫 - Jinji About - Jinji 自我认识 - Jinji 博士屯和大农村 - Jinji Robot Dreams - Jinji 黄粱五载梦 - Jinji The Practice of Management - Jinji My shortcomings - Jinji Replying reviewers' comments - Jinji Curriculum Vitae - Jinji 加州旅馆 - Jinji Protocol for correlation analysis of microbiome and metabolome using 16S rRNA sequencing and untargeted metabolomics - Jinji 少有人走的路 - Jinji 抑郁情绪与抑郁症 - Jinji Spiral Plating and Automatic Colonies Counting - Jinji 回答2022 - Jinji 母亲 - Jinji 北下关 - Jinji 上瘾 - Jinji 师姐 - Jinji MALDI-tof - Jinji 西游记 - Jinji 追求卓越(完美)一定对吗? - Jinji DC开会 - Jinji How to write a publishable manuscript - Jinji 曲-《感谢你的荫庇》 - Jinji 今年的final比以往结束得早一些 - Jinji 世上有没有无缘无故的恨? - Jinji Endless Pain Comes from Ignorance - Jinji
R Language Notes - Jinji
2021-07-28 · via Home on Jinji

Jinji / 2021-07-28


Disclaimer

To save my time finding codes(since I can’t remember all of them), I made some notes here. These codes were all from online resources and I might have made some adjustments or might not. Copyright belongs to the original author, please inform site owner if any infringement.

C

Color

  • add more colors to a color palette
library(RColorBrewer)
# Define the number of colors you want
nb.cols <- 13
mycolors <- colorRampPalette(brewer.pal(12, "Set3"))(nb.cols)
# Set3 has 12 colors
# Create a ggplot with 13 colors 
# Use scale_fill_manual
plot<-ggplot(df, aes(x = x var, y = y var, fill = some factor)) + 
  geom_bar(stat = "identity")+ylab("YY")+
  theme(axis.text.x = element_text(angle = 90))+
  theme(axis.title.x = element_blank())+
  scale_fill_manual(values =mycolors)

L

Legend

  • change legend size
ggplot(df, aes(x=x var, y=y var)) +
  theme(legend.key.size = unit(1, 'cm'), #change legend key size
        legend.key.height = unit(1, 'cm'), #change legend key height
        legend.key.width = unit(1, 'cm'), #change legend key width
        legend.title = element_text(size=14), #change legend title font size
        legend.text = element_text(size=10)) #change legend text font size