Scatter plot with two data sets of uneven values
Show older comments
Hi All,
Is it possible to create a scatter plot using two datasets of uneven values. For example, D1 and D1 both have x values that span 0 120 and y values of different parameters (D1 = oxygen, D2 = chlorine). However, D1 consists of 80 data points, and D2 consists of ~20. Moreover, the x values for D1 and D2 do not overlap.
If not, is there a recommended solution to make this easier? The only thing I can think of is to resample the data to a common axis, but that introduces data that are not real.
Thanks!
9 Comments
Adam Danz
on 10 Jan 2020
"Is it possible to create a scatter plot using two datasets of uneven values"
Sure
scatter(1:5,1:5)
hold on
scatter(10:12, 10:12)
"Moreover, the x values for D1 and D2 do not overlap"
Something tells me we're missing a piece of the picture needed to understand the problem.
Vince Clementi
on 10 Jan 2020
Adam Danz
on 10 Jan 2020
Are D1 and D2 vectors or matricies? I don't understand whether D1 and D2 represent x values (vectors) or [x,y] values (matrices).
In the example you gave, D1 and D2 are vectors of the same length (7 elements). Where do the y values come in?
Maybe you could show us an actual representation of the variables you're working with.
Vince Clementi
on 10 Jan 2020
That's much clearer. So you've got two sets of data, D1 and D2. Each set consists if an nx2 matrix of n [x,y] data points.
The problem still isn't clear, though. Why doesn't one of these solutions solve it?
scatter(D1(:,1),D1(:,2))
hold on
scatter(D2(:,1),D2(:,2))
or
D = [D1; D2];
scatter(D(:,1),D(:,2))
Vince Clementi
on 10 Jan 2020
Adam Danz
on 10 Jan 2020
ahhhhh...... got it now.
Ok, how to you expect that these values are paired? Here are some ideas.
- y values from dataset2 are paired with the first n values of dataset1 (this sounds arbitrary to me; I doubt this is what you want).
- y values from dataset2 are paired with the y values from dataset1 whose x values are closest between the two datasets. Note that this may result in more than 1 coordinate in dataset2 being paired with the same coordinate in dataset1, which is fine.
- Some other rule you have in mind.
Vince Clementi
on 10 Jan 2020
Adam Danz
on 10 Jan 2020
"Option 2 sounds reasonable"
It sounds like this decision hasn't been though out. The results will not be meaningful unless the pairing is meaningful. There are lots of ways to pair the two datasets and each of them will produce a very different result with a different interpretation.
Accepted Answer
More Answers (0)
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
