<p>I would strongly discourage you from making discontinuous axis, it's going to be very confusing for a reader. </p>

<p>The facet plot you proposed seems like a good solution to me. Alternatively you can use log transformation. To demonstrate I made it on simulated data that look appox like yours :</p>

<pre><code>set.seed(940401)

data.plot &lt;- data.frame(Methyl_Average = c(0.05, rbeta(699, 2, 5) + 0.15, runif(300, 0.18, 0.85)),
                        Average_Gene_Expression = c(165, exp(rnorm(999, 3))))

library(ggplot2)
require(gridExtra)

g &lt;- ggplot(data.plot, aes(x = Methyl_Average, y = Average_Gene_Expression))
g1 &lt;-  g + geom_point(color = "steelblue") + theme_bw(base_family = "Times") +
       ggtitle( "Scatter Plot") +
       theme_bw(base_family = "Times") +
       theme(plot.title = element_text(hjust = 0.5))

sc_plot &lt;- g1 +
           labs(x = "Differential Methylation", y = "Differential Expression")
logsc_plot &lt;- g1 + 
              labs(x = "Differential Methylation", y = "Differential Expression (log10 scale)") + 
              scale_y_continuous(trans='log10')

grid.arrange(sc_plot, logsc_plot, ncol = 2)
</code></pre>

<p><a href="https://i.sstatic.net/4aHFH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4aHFH.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2018-05-09T09:57:21.607Z
Nice answer. One minor point: the numbers on the y-axis of the right plot is still `DE`, not `log10(DE)`. The scale is log transformed but the numbers aren't. I'd call it `Differential Expression (log10 scale)` or something.
heathobrien
CC BY-SA 4.0
2018-05-09T11:06:38.763Z
fair point, but I am too lazy to redo the image, I changed it in the code...
Kamil S Jaron
CC BY-SA 4.0
2018-05-09T09:46:13.630Z
2018-05-09T15:49:31.037Z
2018-05-09T15:49:31.037Z
Kamil S Jaron
<p>I am using <code>ggplot2</code> to plot a scatter plot.</p>

<pre><code>library(ggforce) # required by facet_zoom

g &lt;- ggplot(data.plot, aes(x = Methyl_Average, y = Average_Gene_Expression))  
g1 &lt;-  g + geom_point(color = "steelblue") + theme_bw(base_family = "Times") +
       ggtitle( "Scatter Plot") + 
       theme_bw(base_family = "Times") +
       theme(plot.title = element_text(hjust = 0.5))    
</code></pre>

<p><a href="https://i.sstatic.net/uKecW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uKecW.png" alt="enter image description here"></a></p>

<p>As most of my data points are in the range of 0 - 200 on y-axis, I want to zoom this section. I tried doing it using <code>facet_zoom</code> from <code>ggforce</code> package :</p>

<pre><code>g1 + facet_zoom(y = Average_Gene_Expression &gt; 0 &amp; Average_Gene_Expression &lt; 200)    
</code></pre>

<p><a href="https://i.sstatic.net/iNNjD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iNNjD.png" alt="enter image description here"></a></p>

<p>Instead of two plots in one figure, I want one plot (like first figure), where 80% of y-axis displays the data points in the range of 0 - 200 and 20% of the y-axis displays the remaining and x-axis unaltered. Which function/package should I use do it in R? </p>

CC BY-SA 4.0
2018-05-06T21:11:41.763Z
I'm voting to close this question as off-topic because it is not about bioinformatics, it is about representing results. Which might be better suited in academic.stackexchange.com
llrs
CC BY-SA 4.0
2018-05-07T11:07:14.510Z
I voted to leave it open because I think visualization is an integral part of bioinformatics and the presented data to be visualized are obviously very domain-bioinformatic specific.
Kamil S Jaron
CC BY-SA 4.0
2018-05-07T15:19:48.577Z
As per [this link](https://groups.google.com/d/msg/ggplot2/jSrL_FnS8kc/MvzM_2_jiSIJ) this is not possible with ggplot2. Also check this [answer](https://stackoverflow.com/a/7195107/2886003).
llrs
<r><visualization><ggplot2>
How to enlarge a section of y-axis?
# How to enlarge a section of y-axis?

(Asked by: username_0 on 2018-05-05)

I am using ggplot2 to plot a scatter plot.
library(ggforce) # required by facet_zoom

g <- ggplot(data.plot, aes(x = Methyl_Average, y = Average_Gene_Expression))  
g1 <-  g + geom_point(color = "steelblue") + theme_bw(base_family = "Times") +
       ggtitle( "Scatter Plot") + 
       theme_bw(base_family = "Times") +
       theme(plot.title = element_text(hjust = 0.5))    


As most of my data points are in the range of 0 - 200 on y-axis, I want to zoom this section. I tried doing it using facet_zoom from ggforce package :
g1 + facet_zoom(y = Average_Gene_Expression > 0 & Average_Gene_Expression < 200)    


Instead of two plots in one figure, I want one plot (like first figure), where 80% of y-axis displays the data points in the range of 0 - 200 and 20% of the y-axis displays the remaining and x-axis unaltered. Which function/package should I use do it in R?

**Tags:** r, visualization, ggplot2
> **Comments:**
> **username_1**: I'm voting to close this question as off-topic because it is not about bioinformatics, it is about representing results. Which might be better suited in academic.stackexchange.com  
> **username_2**: I voted to leave it open because I think visualization is an integral part of bioinformatics and the presented data to be visualized are obviously very domain-bioinformatic specific.  
> **username_1**: As per [this link](https://groups.google.com/d/msg/ggplot2/jSrL_FnS8kc/MvzM_2_jiSIJ) this is not possible with ggplot2. Also check this [answer](https://stackoverflow.com/a/7195107/2886003).  

---

## 1 answers

### Answer by username_2 on 2018-05-09. Score: 5

I would strongly discourage you from making discontinuous axis, it's going to be very confusing for a reader. 
The facet plot you proposed seems like a good solution to me. Alternatively you can use log transformation. To demonstrate I made it on simulated data that look appox like yours :
set.seed(940401)

data.plot <- data.frame(Methyl_Average = c(0.05, rbeta(699, 2, 5) + 0.15, runif(300, 0.18, 0.85)),
                        Average_Gene_Expression = c(165, exp(rnorm(999, 3))))

library(ggplot2)
require(gridExtra)

g <- ggplot(data.plot, aes(x = Methyl_Average, y = Average_Gene_Expression))
g1 <-  g + geom_point(color = "steelblue") + theme_bw(base_family = "Times") +
       ggtitle( "Scatter Plot") +
       theme_bw(base_family = "Times") +
       theme(plot.title = element_text(hjust = 0.5))

sc_plot <- g1 +
           labs(x = "Differential Methylation", y = "Differential Expression")
logsc_plot <- g1 + 
              labs(x = "Differential Methylation", y = "Differential Expression (log10 scale)") + 
              scale_y_continuous(trans='log10')

grid.arrange(sc_plot, logsc_plot, ncol = 2)

> **Comments:**
> **username_3**: Nice answer. One minor point: the numbers on the y-axis of the right plot is still `DE`, not `log10(DE)`. The scale is log transformed but the numbers aren't. I'd call it `Differential Expression (log10 scale)` or something.  
> **username_2**: fair point, but I am too lazy to redo the image, I changed it in the code...  

---

