How to fixed the axis order in hist3 plot?

1 visualización (últimos 30 días)
Andi
Andi el 4 de Jun. de 2022
Respondida: Star Strider el 4 de Jun. de 2022
Hi everyone,
My script works well but there is only one issue, it gives vertical axis as reverse (higher to lower (46 to 45 instead of 45 to 46: Figure attached)
clear all
clc
axial_cat=readmatrix('axil_cat.csv'); % Axil catalog
axial_lat=axial_cat(:,7);
axial_long=-1*axial_cat(:,8);
data=[axial_long axial_lat];
figure;
resolution = [50, 50]; % This defines the how many bins you want 1000mm/10 = 100mm bin size
[n, q] = hist3(data, resolution);
imagesc(q{:}, n');
xlabel('length [mm]');
ylabel('length [mm]');
c = colorbar;
c.Label.String = 'Amount';
set(gca,'ColorScale','log')
Problem 2: I attempt to solve this issue with another approch. Altough the axis issues is solved by second approch but resolution is limited like 10 by 10, where i need 50 by 50;
My attempt is as below:
figure;
hist3(F,'CdataMode','auto')
xlabel('Longitude (W{\circ})')
ylabel('Latitude (N{\circ})')
xlim([-130.05 -129.95])
ylim([45.9 46])
yticks(45.9:0.05:46);
% ax=gca
% ax.yTick = 45.9:2:46;
colorbar
set(gca,'ColorScale','log')
a = colorbar;
a.Label.String = 'Event count';
view(2)
figure shows 10 by 10 resolution, how can i increase resolution in second case.

Respuesta aceptada

Star Strider
Star Strider el 4 de Jun. de 2022
The problem may be using imagesc.
Try
set(gca, 'YDir','normal')
x = randn(100,1);
y = randn(100,1);
data = [x y];
figure;
resolution = [50, 50]; % This defines the how many bins you want 1000mm/10 = 100mm bin size
[n, q] = hist3(data, resolution);
imagesc(q{:}, n');
figure;
resolution = [50, 50]; % This defines the how many bins you want 1000mm/10 = 100mm bin size
[n, q] = hist3(data, resolution);
imagesc(q{:}, n')
set(gca, 'YDir','normal')
.

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by