Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a solution just using <code>plot()</code>, <code>text()</code>, and <code>arrows()</code>. The <code>for</code> loop is a bit cluttered, but will work for larger data sets and it should be easy to play with the plot and arrows:</p> <pre><code>plot(myd$X,myd$Y, col='white', type="p", main="", ylab="", xlab="", axes = FALSE, ylim = c(min(myd$Y)*.8, max(myd$Y)*1.2), xlim = c(min(myd$X)*.8, max(myd$X)*1.2)) child = data.frame() child = myd[!is.na(myd$Parent1),] DArrows = matrix(0,nrow(child),4); MArrows = matrix(0,nrow(child),4); for (n in 1:nrow(child)){ d&lt;-child[n,]; c1&lt;-myd$indvidual==as.character(d$Parent1); b1&lt;-myd[t(c1)]; c2&lt;-myd$indvidual==as.character(d$Parent2); b2&lt;-myd[t(c2)]; DArrows[n, 1]=as.double(d$X) DArrows[n, 2]=as.double(d$Y) DArrows[n, 3]=as.double(b1[4]) DArrows[n, 4]=as.double(b1[5]) MArrows[n, 1]=as.double(d$X) MArrows[n, 2]=as.double(d$Y) MArrows[n, 3]=as.double(b2[4]) MArrows[n, 4]=as.double(b2[5]) } arrows(DArrows[,3],DArrows[,4],DArrows[,1],DArrows[,2],lwd= 2, col = "blue",length=".1") arrows(MArrows[,3],MArrows[,4],MArrows[,1],MArrows[,2],lwd=2, col = "red",length=".1") par(new=TRUE) plot(myd$X,myd$Y,type = "p", main = "", ylab = "", xlab = "",cex = myd$pchsize, axes = FALSE, pch = 21, ylim = c(min(myd$Y)*.8, max(myd$Y)*1.2), xlim=c(min(myd$X)*.8, max(myd$X)*1.2), bg = myd$fillcol,fg = 'black') text(1.12*myd$X, .85*myd$Y, myd$indvidual) arrows((DArrows[,3]+DArrows[,1])/2, (DArrows[,4]+DArrows[,2])/2, DArrows[,1], DArrows[,2], lwd = 2, col = "blue", length = ".1") arrows((MArrows[,3]+MArrows[,1])/2, (MArrows[,4]+MArrows[,2])/2, MArrows[,1], MArrows[,2], lwd = 2, col = "red", length = ".1") </code></pre> <p><img src="https://i.imgur.com/ZupAW.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. 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