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

推荐订阅源

IT之家
IT之家
A
About on SuperTechFans
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
博客园 - Franky
D
Docker
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
Last Week in AI
Last Week in AI
U
Unit 42
F
Fortinet All Blogs
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
P
Proofpoint News Feed
月光博客
月光博客
G
Google Developers Blog

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