Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way to achieve the desired look is to change data produced while plotting.</p> <p>First, save plot as object and then use <code>ggplot_build()</code> to save all parts of plot data as object. </p> <pre><code>p&lt;-ggplot(Data, aes(Site, Height,fill=Month)) + geom_boxplot() dd&lt;-ggplot_build(p) </code></pre> <p>List element data contains all information used for plotting.</p> <pre><code>dd$data [[1]] fill ymin lower middle upper ymax outliers notchupper notchlower x PANEL 1 #F8766D -1.136265 -0.2639268 0.1978071 0.5318349 0.9815675 0.5954014 -0.1997872 0.75 1 2 #00BA38 -1.264659 -0.6113666 0.3190873 0.7915052 1.0778202 1.0200180 -0.3818434 1.00 1 3 #F8766D -1.329028 -0.4334205 0.3047065 1.0743448 1.5257798 1.0580462 -0.4486332 1.75 1 4 #00BA38 -1.137494 -0.7034188 -0.4466927 -0.1989093 0.1859752 -1.759846 -0.1946196 -0.6987658 2.00 1 5 #619CFF -2.344163 -1.2108919 -0.5457815 0.8047203 2.3773189 0.4612987 -1.5528617 2.25 1 group weight ymin_final ymax_final xmin xmax 1 1 1 -1.136265 0.9815675 0.625 0.875 2 2 1 -1.264659 1.0778202 0.875 1.125 3 3 1 -1.329028 1.5257798 1.625 1.875 4 4 1 -1.759846 0.1859752 1.875 2.125 5 5 1 -2.344163 2.3773189 2.125 2.375 </code></pre> <p>You are interested in <code>x</code>, <code>xmax</code> and <code>xmin</code> values. First two rows correspond to level <code>A</code>. Those values should be changed. </p> <pre><code>dd$data[[1]]$x[1:2]&lt;-c(0.75,1) dd$data[[1]]$xmax[1:2]&lt;-c(0.875,1.125) dd$data[[1]]$xmin[1:2]&lt;-c(0.625,0.875) </code></pre> <p>Now use <code>ggplot_gtable()</code> and <code>grid.draw()</code> to plot changed data.</p> <pre><code>library(grid) grid.draw(ggplot_gtable(dd)) </code></pre> <p><img src="https://i.stack.imgur.com/B8PIj.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload