Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top