yyplot 应用
---
title: "Untitled"
author: "xuefliang"
date: "6/15/2019"
output: html_document
---
```{r}
devtools::install_github("GuangchuangYu/yyplot")
library(yyplot)
library(tidyverse)
```
## 关键字
键入你要搜索的关键字
```{r}
term <- c("Lung Adenocarcinoma", "NSCLC", "SCLC")
```
进行检索,指定起止年
```{r}
pm <- pubmed_trend(term, year=2010:2019)
```
绘图
```{r}
plot(pm) + theme_bw()
```
注意纵坐标是一个比例,该关键字发表文章数与当年文章总数的比例值,我们也可以灵活一点,只绘制发表文章数目:
```{r}
ggplot(pm, aes(x=year, y=number, color=TERM)) +
geompoint() + geomline() + theme_bw() +
xlab("Year") + ylab("Number of Publication per Year")
```
画出某个研究人员,历年来发表文章的数目
```{r}
pubmedtrend("Yu Guangchuang[Full Author Name]", 2010:2016)
```
```{r}
d <- data.frame(x=rnorm(10), y=rnorm(10), lab=LETTERS[1:10])
p <- ggplot(d, aes(x, y)) +
geomtext(aes(label=lab, color=lab), size=10) +
geom_text(aes(y, x, label=lab), size=3)
```
## 设置字体
一次性设置所有字体包括family, fontface, color, size等
```{r}
g <- set_font(p, family="Times",
fontface="italic", color="firebrick", size=5)
plot(g)
```
只想改字体,但不想改文字大小和颜色
```{r}
g2 <- setfont(p, family="Arial", fontface="italic")
plot(g2)
cowplot::plotgrid(p, g, g2, ncol=3)
```
## 二维码
```{r}
ggqrcode("I love you")
```
## joyplot图,山峰叠峦
```{r}
library(ggjoy)
ggplot(diamonds, aes(x=price, y=cut, fill=cut,
group=cut, height=..density..)) +
geomjoy(scale=4) +
scaleydiscrete(expand=c(0.01, 0)) +
scalexcontinuous(expand=c(0, 0)) +
themejoy()
```
```{r}
library(ggridges)
ggplot(diamonds) +
aes(x = carat, y = clarity, color = clarity, fill = clarity) +
geomdensityridges(alpha = 0.75) +
theme_ridges()
```
评论
发表评论