Ai
1 Star 0 Fork 3

weijiew/R-graph-gallery

forked from 程序员维C社区/graph 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
226-plot-types-for-circular-plot.Rmd 4.90 KB
一键复制 编辑 原始数据 按行查看 历史
holtzy 提交于 2019-06-11 05:54 +08:00 . circular almost OK
title descriptionMeta descriptionTop sectionText sectionLink DataToVizText DataToVizLink url output
Available circular chart types with circlize
The circlize package allows to build circular charts with R. Several chart types are offered: bar, scatter, line, abline and more. This post shows how to build them.
The `circlize` package allows to build [circular charts](chord-diagram.html) with R. Several chart types are offered: bar, scatter, line, abline and more. This post shows how to build them.
Chord section
chord-diagram.html
Data to Viz
data-to-viz.com/graph/chord.html
226-plot-types-for-circular-plot
html_document
self_contained mathjax lib_dir template css toc toc_float toc_depth df_print
false
default
libs
template_rgg.html
style.css
true
true
2
paged
```{r global options, include = FALSE} knitr::opts_chunk$set( warning=FALSE, message=FALSE) ```
# Circular Scatterplot ***
Circular scatterplot has already been extensively described in chart [#224](224-basic-circular-plot.html) and [#225](225-circular-plot-custom-a-track.html). Here is a reminder:
```{r thecode, echo=FALSE, out.width = "100%", fig.height=7} # Upload library library(circlize) circos.par("track.height" = 0.4) # Create data data = data.frame( factor = sample(letters[1:8], 1000, replace = TRUE), x = rnorm(1000), y = runif(1000) ) # Step1: Initialise the chart giving factor and x-axis. circos.initialize( factors=data$factor, x=data$x ) # Step 2: Build the regions. circos.trackPlotRegion(factors = data$factor, y = data$y, panel.fun = function(x, y) { circos.axis() }) # Step 3: Add points circos.trackPoints(data$factor, data$x, data$y, col="#69b3a2") ```
```{r thecode, eval=FALSE} ``` # Circular Line chart ***
It is possible to switch to line chart using the `circos.trackLines()` function. Visit the [line chart](line-plot.html) section of the gallery to learn how to customize that kind of chart.
```{r thecode2, echo=FALSE, out.width = "100%", fig.height=7} # Upload library library(circlize) circos.par("track.height" = 0.4) # Create data data = data.frame( factor = sample(letters[1:8], 1000, replace = TRUE), x = rnorm(1000), y = runif(1000) ) # Step1: Initialise the chart giving factor and x-axis. circos.initialize( factors=data$factor, x=data$x ) # Step 2: Build the regions. circos.trackPlotRegion(factors = data$factor, y = data$y, panel.fun = function(x, y) { circos.axis() }) # Step 3: Add points circos.trackLines(data$factor, data$x[order(data$x)], data$y[order(data$x)], col = rgb(0.1,0.5,0.8,0.3), lwd=2) ```
```{r thecode2, eval=FALSE} ``` # Vertical ablines ***
The `circos.trackLines()` function can also be used to display vertical ablines.
```{r thecode3, echo=FALSE, out.width = "100%", fig.height=7} # Upload library library(circlize) circos.par("track.height" = 0.4) # Create data data = data.frame( factor = sample(letters[1:8], 1000, replace = TRUE), x = rnorm(1000), y = runif(1000) ) # Step1: Initialise the chart giving factor and x-axis. circos.initialize( factors=data$factor, x=data$x ) # Step 2: Build the regions. circos.trackPlotRegion(factors = data$factor, y = data$y, panel.fun = function(x, y) { circos.axis() }) # Step 3: Add points circos.trackLines(data$factor, data$x[order(data$x)], data$y[order(data$x)], col = rgb(0.1,0.5,0.8,0.3), lwd=2, type="h") ```
```{r thecode3, eval=FALSE} ``` # Circular histogram ***
Note that each plot type must be coherent with what you specified in the `circos.trackPlotRegion` function. You have to specify an Y axis for a scatterplot as seen before. But not for a histogram that is built with `circos.trackHist()`.
```{r thecode4, echo=FALSE, out.width = "100%", fig.height=7} # Upload library library(circlize) circos.par("track.height" = 0.4) # Create data data = data.frame( factor = sample(letters[1:8], 1000, replace = TRUE), x = rnorm(1000), y = runif(1000) ) # Step1: Initialise the chart giving factor and x-axis. circos.initialize( factors=data$factor, x=data$x ) circos.trackHist(data$factor, data$x, bg.col = "white", col = "#69b3a2") ```
```{r thecode4, eval=FALSE} ```
```{r, echo=FALSE} htmltools::includeHTML("htmlChunkRelatedFlow.html") ```
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/weijiew/R-graph-gallery.git
git@gitee.com:weijiew/R-graph-gallery.git
weijiew
R-graph-gallery
R-graph-gallery
master

搜索帮助