How to fix the event density within bins?

1 view (last 30 days)
Adnan Barkat
Adnan Barkat on 25 Jun 2022
Answered: dpb on 25 Jun 2022
Hi everyone,
My script is working well, but i unable to descritize within each bin.
Here is my script:
clear all
data_cat=readmatrix('data.csv'); %
data=[data_long data_lat];
resolution = [90, 90];
[n, q] = hist3(data, resolution);
imagesc(q{:}, n');
xlabel('Longitude (W{\circ})')
ylabel('Latitude (N{\circ})')
xlim([-130.05 -129.95])
ylim([45.9 46])
a = colorbar;
a.Label.String = 'Event count';
set(gca, 'YDir','normal')
here is what i get
here is what , I am looking for (e.g. grid lines at an interval of 0.01)
Thank you!

Answers (1)

dpb on 25 Jun 2022
If you want 10 bins each direction, then change the resolution to match; your code use 90 in each direction which will give the much finer/smaller individual squares.
You can use grid on to draw the grids, setting
will let you customize the apperance. Major grid lines show only on tick values; you'll set the tick values at the locations wanted; you may then want to set the tick labels independently. I'd also then set the
xtickformat('%0.2f'); ytickformat('%0.2f')
so get same precision displayed on all tick labels -- this just irritates me no end isn't done by default; it's just plain ugly as is with the default '%g'
I didn't experiment to see with your ranges if you just might get lucky and get the other gridlines with minor ticks where you want them; unfortunately, you can't control the number nor placement of them; they're either on or off and the number between major ticks is internally generated.



Community Treasure Hunt

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

Start Hunting!