I have a dataframe which I have constructed by interpolating a series of origin destination points (they relate to a cycle share scheme that used to run in Seattle).
I've called the dataframe interpolated_flows:
line_id      long      lat seg_num count
1       1 -122.3170 47.61855       1   155
2       1 -122.3170 47.61911       2   155
3       1 -122.3170 47.61967       3   155
4       1 -122.3170 47.62023       4   155
5       1 -122.3169 47.62079       5   155
6       1 -122.3169 47.62135       6   155
What I would like to do (and I think is relatively simple if you know ggplot) is to plot these flows (lines) with the width of a line determined by the count and the gradient determined by the seg_num. 
This is my attempt so far:
#Create variables to store relevant data for simplicity of code
X <- interpolated_flows$long
Y <- interpolated_flows$lat
sgn <- interpolated_flows$seg_num
ct <- interpolated_flows$count
#Create a map from flow data and include the bounded box as a base
g <- ggplot(interpolated_flows,aes(x=X, y=Y),group=interpolated_flows$line_id,color=sgn)
map <- ggmap(seattle_map,base_layer = g)
map <- map + geom_path(size=as.numeric(ct)/100,alpha=0.4)+
  scale_alpha_continuous(range = c(0.03, 0.3))+coord_fixed(ratio=1.3)+
  scale_colour_gradient(high="red",low="blue")
png(filename='Seattle_flows_gradient.png')
print(map)
dev.off()
And I end up with the image attached. I have spent a long time playing around with various parameters in the plotting part of the code but without success so would really appreciate if someone could point me in the right direction.
Edit:
base <- ggplot(interpolated_flows,aes(x=X, y=Y))
map <- ggmap(seattle_map,base_layer = g)
map <- map+geom_path(aes(color=seg_num,size=as.numeric(count)))+
  scale_size_continuous(name="Journey Count",range=c(0.05,0.4))+
  scale_color_gradient(name="Journey Path",high="white",low="blue",breaks=c(1,10), labels=c('Origin','Destination'))+
  coord_fixed(ratio=1.3)+scale_x_continuous("", breaks=NULL)+
  scale_y_continuous("", breaks=NULL)
png(filename='Seattle_flows_gradient.png')
print(map)
dev.off()
This is the plot I have now got to which looks like this. I have only two questions - 1) does anyone know a way to improve the resolution of the background map? I tried changing the zoom parameter in the get_map function but it didn't seem to help. 2) The lines I have plotted seem very 'white' heavy. It doesn't look to me like the gradient is evenly distributed. Anyone have any ideas why this would be and how to fix?


ggplotmethodology, and that's probably why your color mapping isn't working. When you passinterpolated_flowsas your firstggplotargument, that means you can reference columns by their names without usinginterpolated_flows$column, you can just usecolumn. So fix that and see if the gradient maps correctly. - Mako212