Answers.Body: <p>Axes for <code>ggplot</code>s can be controlled via <code>xlim()</code> and <code>ylim()</code> functions. You can try:</p>
  
  <pre><code>your_ggplot_object +
    ylim(-5,20) # assuming that you want the gene labels to be readabe, not clear from your post
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-19T12:31:14.763Z
Answers.Text: > p1 +
  +     xlim() +
  +     ylim(-5,20) 
  Error in UseMethod("limits") : 
    no applicable method for 'limits' applied to an object of class "NULL"
  >
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-19T12:40:21.220Z
Answers.Text: I have realized that the function EnhancedVolcano has a "ylim" argument and its lower limit is 0, please try "ylim = c(-5, max(-log10(toptable[,y]), na.rm=TRUE) + 5)" within EnhancedVolcano.
Answers.UserDisplayName: haci
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-19T12:52:22.373Z
Answers.Text: Sorry what is the y here? when I am placing pvalue, says that Error in `[.data.frame`(res_responders, , pvalue) : 
    object 'pvalue' not found
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-19T13:24:05.473Z
Answers.Text: Please check the documentation of the function EnhancedVolcano() and play a little bit different arguments. For you case ssetting the ylim argument "ylim = (-5,20)" might help.
Answers.UserDisplayName: haci
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-19T12:18:06.333Z
Answers.LastActivityDate: 2019-09-19T14:46:12.947Z
Answers.LastEditDate: 2019-09-19T14:46:12.947Z
Answers.UserDisplayName: haci
Body: <p>By EnhancedVolcano R package I have this plot with this code</p>
  
  <pre><code>    &gt; head(res1)
           baseMean log2FoldChange     lfcSE        stat     pvalue      padj
  SAMD11   237.7975     0.03584334 1.3244737  0.02706233 0.97841002 0.9971691
  NOC2L   4751.0381    -0.62090622 0.6500115 -0.95522347 0.33946470 0.9239759
  KLHL17   735.0849    -0.95126291 0.8417444 -1.13010892 0.25843033 0.8926461
  PLEKHN1 1117.5598    -2.11321359 1.0411108 -2.02976816 0.04238011 0.6350143
  PERM1    409.0061    -2.32444927 1.1255813 -2.06511000 0.03891259 0.6285916
  HES4    1088.7549     0.28395931 0.9091259  0.31234320 0.75477971 0.9866881
  &gt;
  p= EnhancedVolcano(res1,
      lab = rownames(res1),
      x = 'log2FoldChange',
      y = 'pvalue',
      xlim = c(-5, 8))
  </code></pre>
  
  <p>I have stored my plot in an object</p>
  
  <pre><code>&gt; class(p)
  [1] "gg"     "ggplot"
  </code></pre>
  
  <p><a href="https://i.sstatic.net/X32hE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/X32hE.png" alt="enter image description here"></a></p>
  
  <p>I want to limit the axis length in this plot in the other word shrining my plot more but I don't know how to do that. <code>For example y axis be from 0 to 10 instead of 20</code></p>
  
  <p>Any help please </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-09-19T12:11:00.443Z
Comments.Text: Could you clarify what do you man by "limit the axis length"?  Do you want it for instance to reach just from -4 to 4 or do you want a wider plot? What kind of searches did you make? Also if you could include a reproducible example, see [reprex](https://reprex.tidyverse.org/), it would be easier for people to understand and work with your problem
Comments.UserDisplayName: llrs
Tags: <r><rna-seq><ggplot2>
Title: Changing the axis limits of ggplot objects
ThreadText: # Changing the axis limits of ggplot objects
  
  (Asked by: username_0 on 2019-09-19)
  
  By EnhancedVolcano R package I have this plot with this code
  
  ```
      > head(res1)
           baseMean log2FoldChange     lfcSE        stat     pvalue      padj
  SAMD11   237.7975     0.03584334 1.3244737  0.02706233 0.97841002 0.9971691
  NOC2L   4751.0381    -0.62090622 0.6500115 -0.95522347 0.33946470 0.9239759
  KLHL17   735.0849    -0.95126291 0.8417444 -1.13010892 0.25843033 0.8926461
  PLEKHN1 1117.5598    -2.11321359 1.0411108 -2.02976816 0.04238011 0.6350143
  PERM1    409.0061    -2.32444927 1.1255813 -2.06511000 0.03891259 0.6285916
  HES4    1088.7549     0.28395931 0.9091259  0.31234320 0.75477971 0.9866881
  >
  p= EnhancedVolcano(res1,
      lab = rownames(res1),
      x = 'log2FoldChange',
      y = 'pvalue',
      xlim = c(-5, 8))
  
  ```
  
  I have stored my plot in an object
  
  ```
  > class(p)
  [1] "gg"     "ggplot"
  
  ```
  
  [![enter image description here](https://i.sstatic.net/X32hE.png)](https://i.sstatic.net/X32hE.png)
  
  I want to limit the axis length in this plot in the other word shrining my plot more but I don't know how to do that. `For example y axis be from 0 to 10 instead of 20`
  
  Any help please
  
  **Tags:** r, rna-seq, ggplot2
  
  > **Comments:**
  > **username_1**: Could you clarify what do you man by "limit the axis length"?  Do you want it for instance to reach just from -4 to 4 or do you want a wider plot? What kind of searches did you make? Also if you could include a reproducible example, see [reprex](https://reprex.tidyverse.org/), it would be easier for people to understand and work with your problem  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-09-19. Score: 4
  
  Axes for `ggplot`s can be controlled via `xlim()` and `ylim()` functions. You can try:
  
  ```
  your_ggplot_object +
    ylim(-5,20) # assuming that you want the gene labels to be readabe, not clear from your post
  
  ```
  
  > **Comments:**
  > **username_0**: > p1 + +     xlim() + +     ylim(-5,20)  Error in UseMethod("limits") :    no applicable method for 'limits' applied to an object of class "NULL" >  
  > **username_2**: I have realized that the function EnhancedVolcano has a "ylim" argument and its lower limit is 0, please try "ylim = c(-5, max(-log10(toptable[,y]), na.rm=TRUE) + 5)" within EnhancedVolcano.  
  > **username_0**: Sorry what is the y here? when I am placing pvalue, says that Error in `[.data.frame`(res_responders, , pvalue) :    object 'pvalue' not found  
  > **username_2**: Please check the documentation of the function EnhancedVolcano() and play a little bit different arguments. For you case ssetting the ylim argument "ylim = (-5,20)" might help.  
  
  ---
  
  