Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay the correct filled shape in legend of ggplot2
    primarykey
    data
    text
    <p>I have following dataset:</p> <pre><code>structure(list(com = c("v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "v", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "v", "v", "v", "v", "v", "v", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t", "t" ), d = c(0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4), strf = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0, 0.5, 0, 0, 0, 0.25, 0, 1, 0, 0, 0, 0.5, 1, 1, 1.5, 0.25, 1, 1, 1.5, 1.5, 2, 0.5, 1, 3, 2.5, 2.5, 2, 0, 0.5, 0.25, 0.5, 0.5, 1, 0, 0.5, 1.5, 2, 1, 2.75, 0, 0.5, 0, 0.5, 1.5, 2, 2.5, 3), side = c(2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4), auf = c("h", "h", "h", "h", "h", "h", "l", "l", "l", "l", "l", "l", "h", "h", "h", "h", "h", "h", "l", "l", "l", "l", "l", "l", "h", "h", "h", "h", "h", "h", "l", "l", "l", "l", "l", "l", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "l", "l", "l", "l", "l", "l"), zud = c(10.8823529411765, 10.8823529411765, 8.52941176470588, 8.52941176470588, 5, 5, 5, 5, 8.52941176470588, 8.52941176470588, 10.8823529411765, 10.8823529411765, 9.25, 9.25, 7.25, 7.25, 4.25, 4.25, 4.25, 4.25, 7.25, 7.25, 9.25, 9.25, 9.25, 9.25, 7.25, 7.25, 4.25, 4.25, 4.25, 4.25, 7.25, 7.25, 9.25, 9.25, 8.40909090909091, 8.40909090909091, 6.59090909090909, 6.59090909090909, 3.86363636363636, 3.86363636363636, 7.70833333333333, 7.70833333333333, 6.04166666666667, 6.04166666666667, 3.54166666666667, 3.54166666666667, 6.60714285714286, 6.60714285714286, 5.17857142857143, 5.17857142857143, 3.03571428571429, 3.03571428571429, 3.03571428571429, 3.03571428571429, 5.17857142857143, 5.17857142857143, 6.60714285714286, 6.60714285714286 ), dru = c(420, 540, 420, 370, 280, 170, 410, 250, 440, 580, 710, 530, 360, 300, 270, 240, 190, 190, 290, 270, 380, 330, 450, 480, 320, 320, 285, 285, 190, 190, 290, 290, 420, 420, 450, 450, 310, 300, 270, 230, 210, 210, 345, 305, 250, 270, 205, 205, 290, 310, 270, 280, 270, 260, 340, 350, 420, 410, 510, 500)), .Names = c("com", "d", "strf", "side", "auf", "zud", "dru"), row.names = c(NA, 60L), class = "data.frame") </code></pre> <p>and this code:</p> <pre><code>s &lt;- ggplot( data2 , aes(zud, dru)) s + geom_point(aes( shape=com, size=strf, fill=as.factor(d)) , alpha=0.5) + scale_fill_hue( h=c(90, -100), l=seq(80, 20,length.out = 5 ), c=90) + scale_size(range = c(2 , 10)) + ylim(100, 700) + scale_shape_manual(values=c(21,22)) + facet_grid(side ~ auf) + guides(fill = guide_legend(override.aes = list(shape = 21, size=5)), shape = guide_legend(override.aes = list( size=5)), size = guide_legend(override.aes = list( shape=21, fill="grey70"))) </code></pre> <p>And that gives me this correct plot:</p> <p><img src="https://i.stack.imgur.com/uFMIS.png" alt="correct"></p> <p>But when I try to change the square shape into a triangle by changing this code snippet</p> <pre><code>+ scale_shape_manual(values=c(21,22)) </code></pre> <p>into </p> <pre><code>+ scale_shape_manual(values=c(21,24)) </code></pre> <p>the legend for the shape is incorrect (empty for the second shape).</p> <p><img src="https://i.stack.imgur.com/JkVoC.png" alt="incorrect"></p> <p>What should I do to get the correct legend shape for this filled shapes? (I am running ggplot2’ version 0.9.3.1 and R 3.0.1 on an Windows 64 bit machine) </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.
 

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