2D scatter-plot with colorbar

1,023 views (last 30 days)
Ebtesam Farid
Ebtesam Farid on 10 Jul 2021
Answered: ANKUR KUMAR on 11 Jul 2021
Hello everyone,
I have 2 variables, X, and Y represent the precipitation measurements from two different datasets, and I want to plot them as a scatterplot with colorbar representing the no of coincident points in each color. I tried to use scatter function, but I found I have to input Z (which represent here the no of measurements in bin) to the function to plot colored scatter plot, and I don't know how to get the count of the measurements in each color as input.
any suggestions, please?? Thanks

Answers (1)

ANKUR KUMAR on 11 Jul 2021
You can represent the no of measurements in bin as the fourth argument while calling the scatter plot. Here is the sample plot using random data.
x = linspace(0,2*pi,50);
y = sin(x) + randi(50,1,50);
c = linspace(1,10,length(x));
colormap jet

Community Treasure Hunt

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

Start Hunting!