1
我的矩陣包含離散值1
,2
和3
,它(在這種情況下)是用於red
,blue
和代碼。彩條顯示這些標籤的位置,我最初不會指望它們是。我想它與方式有關,顏色被分配(例如,2.4
不是,但是blue
),其不假定離散值。MATLAB /倍頻程:調整刻度位置/取向爲彩條軸
我一直希望像「TickLabelAlignment
」或類似的設置,但找不到任何東西。所以我不得不「手動」調整位置,這是成功的。然而,是否有更普遍的方式來做到這一點?我覺得我正在使用一種解決方法。
例子:
% set gnuplot as graphics toolkit, set custum colormap and create exemplary matrix
graphics_toolkit('gnuplot');
colormap([1 0 0; 0 1 0; 0 0 1]);
A = randi([1 3], 5, 5);
% plot with standard settings
subplot (2, 1, 1);
imagesc(A);
caxis([1 3]);
mycb = colorbar();
set(mycb, 'YTick', [1 2 3], 'YTickLabel', {'red', 'green', 'blue'});
% plot with adjusted tick positions (the way I want the colorbar to look like)
subplot (2, 1, 2);
imagesc(A);
caxis([1 3]);
mycb = colorbar();
set(mycb, 'YTick', [4/3 2 8/3], 'YTickLabel', {'red', 'green', 'blue'});