Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Xticklabels between Xticks

Subject: Xticklabels between Xticks

From: Hermano Cappa

Date: 11 Aug, 2011 10:09:10

Message: 1 of 1

Hi,

I wrote a program to colour a '1' value green and a '0' value red. Now I want to place the X- and Yticklabels centred between the X- and Yticks. This works fine for my Y-axis but not for my X-axis. Also a white space appears on my figure suddenly. How can I solve these two problems?

A =[1 0; 0 0; 1 1];
[I,J] = size(A);
alphatick = 0.5:1:I+1;
betatick = 0.5:1:J+1;
alphapos = 0.5*diff(alphatick)+alphatick(1:end-1);
betapos = 0.5*diff(betatick)+betatick(1:end-1);
alphalabels = 10:10:30;
betalabels = 100:100:200;

figure
fig(1)=newplot;
set(gcf,'nextplot','add');
set(fig(1),'Ylim',[0.5,3.5],'YTick',alphapos,'YTicklabel',alphalabels);
set(fig(1),'Xlim',[0.5,2.5],'XTick',betapos,'XTicklabel',betalabels);
fig(2)=axes('position',get(fig(1),'position'),'Visible', 'off');
imshow(A,'InitialMagnification','fit')
iptsetpref('ImshowAxesVisible','on');
cmap(1,:) = [1 0 0]; % Green for 1
cmap(2,:) = [0 1 0]; % Red for 0
colormap(cmap);
set(fig(2),'Ylim',[0.5,3.5],'YTick',alphatick,'YTicklabel','');
set(fig(2),'Xlim',[0.5,2.5],'XTick',betatick,'XTicklabel','');
grid on

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us