how to modify the axis labels in the attached plot?
17 ビュー (過去 30 日間)
古いコメントを表示
clc; close all; workspace
coinci = load('Coinc_600_MBq.dat');
Y = coinci(:,1); % angle in radian (0 - 360) values
X = coinci(:,2);
% 2D histogram with 321 bins for X and 641 bins for Y (1 bin = 1mm)
hist_rebin = hist3([Y, X], 'Nbins', [321 641]);
figure(1)
imshow(hist_rebin, []);
xlabel('S'); ylabel('T');
title('');
colormap gray; axis on;
% Output of this plot is attached.
% Now, I want to make a plot with X-labels as:
% '-320','-200','-100','0','100','200','320'.
% To do this, I need to change my bin 641/2 (middle value) as zero, lowest bin as (641-1)/2 as -320 and
% highest bin as (641-1)/2 as 320 as shown in plot by using red color. How to do this?
% Similarly, I want to change radians in y-labels to angles in terms of pi.
% Finally, I want to see the following as the ticks values in my plot:
%xticks([-320 -200 -100 0 100 200 320])
%yticks([pi/2 pi/4 0 pi -pi/4 pi/2])
%xticklabels({'-320','-200','-100','0','100','200','320'})
%yticks(['{\pi}/2', '{\pi}/4', '0', '-{\pi}/4', '-{\pi}/2'])
%How can I do this? Any help is appreciated.
0 件のコメント
回答 (2 件)
Walter Roberson
2020 年 9 月 16 日
編集済み: Walter Roberson
2020 年 9 月 16 日
imshow(hist_rebin, []);
You would change that. Add in the 'XData' and 'YData' options telling imshow where to position the image in data units.
Caution: XData and YData give the coordinates for the centers of the corner pixels in data units. You need to think about whether you want -320 exactly to be the left edge of the image, or if you want -320 exactly to point to the center of the left pixel. Is there data "at" -320, or is -320 where the data "begins" ?
2 件のコメント
Walter Roberson
2020 年 9 月 16 日
No, you do not need to convert to degrees.
However, you should take into account that when you imshow(), unless "hold on" is in effect, imshow() automatically sets the axes YDir to reverse so that the entries with the lowest row number appear at the top of the display.
Star Strider
2020 年 9 月 16 日
I could not get the axis tick labels to show with imshow, so I went with image instead (and a bit of manual editing to import the image):
hist_rebin = imread('1how to modify the axis labels in the attached plot - 2020 09 16.png');
figure
image(hist_rebin)
xlabel('S')
ylabel('T')
Ax = gca;
Ax.TickLabelInterpreter = 'latex';
xt = Ax.XTick;
xtl = {'-320','-200','-100','0','100','200','320'};
xtv = linspace(min(xt), max(xt), numel(xtl));
Ax.XTickLabel = xtl;
yt = Ax.YTick;
ytl = {'$\pi/2$', '$\pi/4$', '0', '$-\pi/4$', '$-\pi/2$'};
ytv = linspace(min(yt), max(yt), numel(ytl));
set(Ax, 'YTick',ytv, 'YTickLabel',ytl)
producing:
I am not certain that the y-tick labels are the way they should be. Use flip or fliplr to reverse them if necessary:
ytl = fliplr(ytl);
.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!