Controlling the arrow shape in ggplot2

I'm making a graph that plots many arrows around the center, sort of like a bicycle tire wheel, but with arrows pointing inward. Inputs such as the number of arrows, etc. are controlled through a brilliant application that calls my plotting function below:

FPlot1<-function(arr.dat,var_explained){
  g<-rasterGrob(img,interpolate=TRUE)
  plot.grid<-ggplot(data=arr.dat,aes(colour=val))+scale_colour_gradient2(low="blue",mid="purple",high="red",midpoint=0,guide="colourbar")+theme_bw()#+coord_fixed()# +facet_grid(pc ~.)
  plot.grid<-plot.grid+
    scale_x_continuous(name="",limits=c(-7,7))+
    scale_y_continuous(name="",limits=c(-7,7))+
    geom_segment(data=arr.dat, aes(x=x2,y=y2,xend=x1,yend=y1,size=abs(val)*4),arrow=arrow(length=unit(.5,"cm")))+
    geom_text(data=arr.dat,aes(x=center+6*cos(angle), y=center+5.3*sin(angle),label=row),colour="black",size=3)+
    annotation_custom(g,xmin=-1,ymin=-1,xmax=1,ymax=1)+
    geom_text(data=arr.dat,aes(x=center,y=center,label=pc),colour="black",size=4,fontface="bold",family="Times")+
    geom_text(data=arr.dat,aes(x=xmid,y=ymid,hjust=1,vjust=1,angle=(txtangle*180/pi),label=val),colour="black",size=4)+
    theme(line=element_blank(),text=element_blank(),line=element_blank())
  return(plot.grid)

}

      

The key question I have is the arrows that look terrible when they get big, as shown in the left arrow below. I looked to see if there is anyway arrow control in ggplot but no luck. I would rather stay with ggplot since I have a single framework that controls all parts of my plot, but if I need to switch, I get it!

Thanks for your help in advance!

Here's a quick screenshot. http://imgur.com/Qn7X5QJ

Data frame that was entered into the above function

structure(list(row = structure(c(3L, 1L, 2L), .Label = c("actualdisplacement", 
"LHPA_wk1", "STD_TissDeform"), class = "factor"), x1 = c(-0.75, 
-0.750000000000001, 1.5), y1 = c(1.29903810567666, -1.29903810567666, 
-3.67394039744206e-16), x2 = c(-2.5, -2.5, 5), y2 = c(4.33012701892219, 
-4.33012701892219, -1.22464679914735e-15), val = c(0.914, 0.371, 
0.068), center = c(0, 0, 0), angle = c(2.0943951023932, 4.18879020478639, 
6.28318530717959), pc = structure(c(1L, 1L, 1L), .Label = "PC1", class = "factor"), 
    xmid = c(-1.625, -1.625, 3.25), ymid = c(2.81458256229943, 
    -2.81458256229942, -7.9602041944578e-16), txtangle = c(-1.0471975511966, 
    1.0471975511966, 6.28318530717959), stringAsFactors = c(1, 
    1, 1)), .Names = c("row", "x1", "y1", "x2", "y2", "val", 
"center", "angle", "pc", "xmid", "ymid", "txtangle", "stringAsFactors"
), row.names = c(NA, -3L), class = "data.frame")

      

+3


source to share





All Articles