help creating plot of type in attached example

Dear MATLAB answers,
I have here a plot that I need to replicate using my own data. I tried looking through help pages with all the different type of plots, but was having difficulty figuring out how to create the scatter type plot with offsets as shown in attached image. I would be able to plot the lines, curves, etc, but those too I would not know how to offset.
Therefore, my question is:
  1. how to create scatter plot of type shown
  2. how to offset scatter/line/curve in standard way shown in image
Thank you in advance for your guidance!
examplePlot.JPG

5 Comments

Are the results actually 'offset'? To me 'offset' indicates that the data should overlap, but has been deliberately moved by a fixed increment in order to make all points more visible. Is this what you mean? It looks to me like there are just three different data sets that appear at regular intervals.
As for creating a scatter plot, I would suggest creating a quick loop for each data set. Somethign like this:
hold on
for i = 1:numdata
scatter(x_values,y_values,formatting) % Where formatting is a string of characters wich dictates the format of the plotted data (color, shape, etc.)
end
Thank you for the response, but yes the data is offset for exactly the reason you described: to make all points more visible. The data would overlap otherwise.
To vertically offset on a linear axis, you just have to add a constant to the data. For the example in the image, assuming the data used to overlap with the blue, a value of ~0.2 was added to the red data and a value of ~0.4 was added to the green data.
scatter(x, y+0.2)
thank you very much - this works! I probably should have been able to figure that out, but what was and still is confusing: wouldn‘t offseting like this make tick marks on y-axis irrelevant to the data we are showing?
Yes, precisely!
Vertical offsets like this obfuscate the dependent variable and the y axis no longer describes the offseted data. Nevertheless, the caption in the figure you shared indeed states that the data were vertically offset.

Sign in to comment.

 Accepted Answer

(comment moved here so that the question is answered)
To vertically offset on a linear axis, you just have to add a constant to the data. For the example in the image, assuming the data used to overlap with the blue, a value of ~0.2 was added to the red data and a value of ~0.4 was added to the green data.
scatter(x, y+0.2)

More Answers (0)

Asked:

on 31 Jan 2019

Answered:

on 1 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!