Note that there are some explanatory texts on larger screens.

plurals
  1. POfacet_wrap and scaling point size
    text
    copied!<p><strong>In short:</strong> I would like to have separate legends for each "panel" of two-panel plot made using <code>facet_wrap</code> . Using <code>facet_wrap(scales="free")</code> works fine for when I want different axis scales, but not for the size of points.</p> <p><strong>Background:</strong> I have data for several samples with three measurements each: <em>x</em>, <em>y</em>, and <em>z</em>. Each sample is from either class 1 or class 2. <em>x</em> and <em>y</em> have the same distributions in each class. However, all the <em>z</em> measurements for class 1 are less than 1.0; <em>z</em> measurements for class 2 range from 0 to 100.</p> <p><strong>Where I'm stuck:</strong> Plot <em>x</em> and <em>y</em> on the x and y axes, respectively. Make the area of each point proportional to its <em>z</em> value.</p> <pre><code>d = matrix(c(runif(100),runif(20)*100),ncol=3) e = data.frame( gl(2,20), d ) colnames(e) = c("class","x","y","z") ggplot( data = e, aes(x=x, y=y, size=z) ) + geom_point() + scale_area() + facet_wrap( ~ class, ncol=1, scales="free" ) </code></pre> <p><img src="https://i.stack.imgur.com/eH0dJ.png" alt="enter image description here"></p> <p><strong>Problem:</strong> Note that the dots on the first panel are difficult to see because they are on the very low end of the scale used for the single legend which ranges from 0 to 100. Is it even possible to have two separate legends (each with a different range) or should I make two plots and combine them with viewports?</p>
 

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