How to fix the event density within bins?

조회 수: 1 (최근 30일)
Andi
Andi 2022년 6월 25일
답변: dpb 2022년 6월 25일
Hi everyone,
My script is working well, but i unable to descritize within each bin.
Here is my script:
clear all
clc
data_cat=readmatrix('data.csv'); %
data_lat=data_cat(:,1);
data_long=-1*data_cat(:,2);
data=[data_long data_lat];
figure;
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])
yticks(45.9:0.05:46);
colorbar
set(gca,'ColorScale','log')
a = colorbar;
a.Label.String = 'Event count';
view(2)
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!

답변 (1개)

dpb
dpb 2022년 6월 25일
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
hAx.GridLineStyle
hAx.GridColor
hAx.GridAlpha
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.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by