Different coloured regions on a scatter plot
Show older comments
I have a g-g diagram where I want to display different regions in different colours (so right acceleration is one colour, pure acceleration is a different one, left acceleration is different, pure left cornering is different and so on). I was able to overlay a plot on top to show left, right and in the middle like this:
sz = 8
scatter(Lat_A, Long_A, sz, 'filled')
ylabel("Longitudinal Acceleration /g")
xlabel("Lateral Acceleration /g")
threshold = 0.4
right = Lat_A(Lat_A>threshold)
left = Lat_A(Lat_A<-threshold)
hold on;
scatter(right, Long_A(Lat_A > threshold), sz, 'g', 'filled');
scatter(left, Long_A(Lat_A < -threshold), sz, 'r', 'filled');
hold off;
However, I'm struggling to factor in the braking and acceleration the same way on the same plot. In simple terms, I want to show (x>0.4, y>0.4), (x<-0.4, y>0.4), (abs(x)< 0.4, y>0.4) etc. as different colours. I'm pretty new to MATLAB so any help would be appreciated.
Accepted Answer
More Answers (1)
"just colouring the points would be enough" <== One of the inputs to scatter is a vector of colors that you want each marker point to have.
help scatter
Categories
Find more on Scatter Plots 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!