문제

I have a figure and I'd like to be able to show the ticks positions (in white) but keep the tick labels (in black). For example, if you try:

imagesc(abs(peaks(10))); colormap('bone');
set(gca,'XTick',0:pi:2*pi,'XTickLabel',{'0', 'p', '2p'},'fontname','symbol');

enter image description here

You can see that the tick positions can't be seen. Matlab's documentation tells that the handle YColor and XColor can be used, but they also control the color of the tick labels. For example: enter image description here

I have tried to get the tick out, but it doesn't look good. I tried playing with an approach similar to the one discussed here, but without success. The last way I can think of is to "manually" rewrite the labels as text objects... Would appreciate your input.

도움이 되었습니까?

해결책

Since there are no independent attributes for the ticks, only tailor-made tricks spring to mind.

The result of this

imagesc(abs(peaks(10)));
colormap('bone');
set(gca, 'XTick', 0:pi:2*pi, 'XTickLabel', {'0', 'p', '2p'}, 'fontname','symbol');
a = gca;
b = copyobj(a, gcf)
set(b, 'Xcolor', [1 1 1], 'YColor', [1 1 1], 'XTickLabel', [], 'YTickLabel', [])

is this

Clone axes and modify attributes

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top