Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My answer is just a proof of concept to demonstrate the feasibility of this plot using <code>grid</code> and <code>bezier</code>. I use <code>lattice</code> to plot the scene and then <code>grid</code> package in the <code>native</code>. It is just a start, I think you can easily complete it.</p> <p><img src="https://i.stack.imgur.com/IKFVB.png" alt="enter image description here"></p> <pre><code>library(grid) library(lattice) dat &lt;- data.frame(x=c(1,1,2,2), y=c(1,2,1,2), weight=c(2,1,1,2), text=c('B','A','B','A')) cols &lt;- colorRampPalette(c("grey", "green"))(nrow(dat)) xyplot(y~x,data=dat,groups=weight, xlim=extendrange(dat$x,f=1), ylim=extendrange(dat$y,f=1), panel=function(x,y,groups,...){ lapply(seq_along(x),function(i){ grid.roundrect(x[i],y[i], width=.5, height=.5*groups[i], gp=gpar(fill=cols[i],lwd=5,col='blue'), def='native') grid.text(x[i],y[i],label=dat$text[i], gp=gpar(cex=5,col='white'), def='native') }) xx &lt;- c(x[1]+0.25, x[1]+0.25, x[3]-0.25, x[3]-0.25) yy &lt;- c(y[1], y[1], y[3], y[3]) grid.bezier(xx, yy, gp=gpar(lwd=3, fill="black"), arrow=arrow(type="closed"), def='native') xx &lt;- c(x[1]+0.25, 1, 2, x[4]-0.25) yy &lt;- c(y[1], 2, 1, y[4]) grid.bezier(xx, yy, gp=gpar(lwd=3, fill="black"), arrow=arrow(type="closed", length=unit(0.5, "inches")), def='native') xx &lt;- c(x[2]+0.25, x[2]+0.25, x[4]-0.25, x[4]-0.25) yy &lt;- c(y[2], y[2], y[4], y[4]) grid.bezier(xx, yy, gp=gpar(lwd=3, fill="black"), arrow=arrow(type="closed", length=unit(0.5, "inches")), def='native') }) </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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