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 Center および File ExchangeAxis Labels についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by