Logarithmic 2D colormap plot
8 次查看(过去 30 天)
显示 更早的评论
I want to scale my 2D dose distribution logarithmically with appropriate tick such as the displayed image. I can't seem to change the ticks accordingly with the scaled values. Could anyone help me?
Code
%% Read 2D dose map
fileID = fopen('2DDoseMap.txt','r');
formatSpec = '%f %f %f %f';
dataarray_size = [4 Inf];
dataarray = fscanf(fileID, formatSpec, dataarray_size);
dataarray = dataarray';
%% Store each column into vectors
% the first three columns in the text file are the x coordinates, y coordinates and intensity values
x = dataarray(:,1); y = dataarray(:,2);
dose = (dataarray(:,3));
%% Rearrange the dose vector into a dose map
xi = unique(x); yi = unique(y);
[X,Y] = meshgrid(xi, yi);
dosemap = reshape(dose, size(X));
% Create a spatial referencing object associated with the image, and
% use the referencing object to set the x- and y-axes limits in the
% world coordinate system
conversion = ( abs(min(xi(:))) + abs(max(xi(:))) ) / length(xi); % in cm/pixel
sizex = size(dosemap, 2);
sizey = size(dosemap, 1);
xmax = sizex * conversion;
ymax = sizey * conversion;
RI = imref2d(size(dosemap));
RI.XWorldLimits = [-xmax/2 xmax/2];
RI.YWorldLimits = [-ymax/2 ymax/2];
%% Plot
h = figure();
set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]);
imshow(dosemap, RI, [], 'colormap', jet(256))
c = colorbar;
c.Label.String = 'Dose (GeV/g per primary)';
set(gca, 'FontSize', 16)
set(gca, 'ColorScale', 'log')
xlabel('cm'); ylabel('cm');
shading interp
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!