r - Scatterplot with trajectory across datasets -


I'm using ggplot2 in r to create scatterplots for two different positions (x, y ) Datasets are as follows:

  x1 y1 x2 y2 1 1.00000000 150.36247 0.50000000 133.27397 2 1.00000000 12 9.62707 0.50000000 120.79893 3 1.00000000 79.94730 0.62500000 78.98120 4 1.00000000 79.78723 0.62500000 81.93014 5 1.00000000 133.47697 0.72727273 192.86557  

I would like to plot the plot on one plot (x1, y1) and (x2, y2), and draw the trapezoid line connecting two points for each line of the dataset example For sample data above (1,150) (1, 150) (0.5, 133) (data from 1 row) and adding a different line (1,129) and (0.5, 120) (data from the row) 2) and so on. Ideally, I would also like to make each line a different color.

I tried to follow the instructions given below to create trajectories, but in my dataset it is according to column instead of grouping rows: and

Currently, my script is a Generates two scatterplots on the graph, but there is no relation between the data points of the same line:

  scatter2  

Any support which you can provide will be greatly appreciated! Thanks!

This can be achieved using geom_segment () . You can find more information here:.

I think that you want to do something here

  scatter2 & lt; -ggplot (data = df, aes (x = x1, y) = y1)) + geom_point (aes (x = x1, y = y1), color = "red") + geom_point (aes (x = x2, y = Y2), color = "blue") + geom_segment (aes (x = x1, y = y1, xend = x2, yend = y2))  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -