```{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}
```