remove empty column at the beginning of pcolor
7 views (last 30 days)
Show older comments
I made a pcolor plot from a 2D matrix. It seems pcolor generates an empty column at the beginning of the plot. Any suggestion how I can remove it? The last row is also missing in the plot.
I check the data that I plotted and it doesn't have a zero column at the beginning.
>> Ge
Ge =
Columns 1 through 12
-0.4418 0 0 0 0 0 0 0 0 -0.4418 0 0
-0.5080 -0.6686 -0.6686 -0.6686 -0.6686 -0.6686 -0.6686 -0.6686 -0.5080 -0.5080 -0.5080 -0.5080
-0.4418 -0.7719 -0.7719 -0.7719 -0.7719 -0.7719 -0.7719 -0.4607 -0.4418 -0.4418 -0.4418 -0.4418
-0.5080 -0.6686 0 0 0 -0.6686 -0.6686 -0.6686 -0.5080 -0.5080 -0.5080 -0.5080
-0.4418 -0.7719 0 0 0 -0.7719 0 0 0 -0.4418 0 0
-0.5080 0 0 0 0 -0.6686 0 -0.6686 -0.5080 -0.5080 -0.5080 -0.5080
-0.4418 -0.4607 -0.7719 -0.4607 -0.7719 -0.4607 -0.4607 -0.7719 -0.4418 0 0 0
-0.4418 -0.7719 -0.7719 -0.7719 -0.4607 -0.7719 -0.7719 -0.7719 -0.4418 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
hAx(3) =subplot(3,2,[3,4]);
hAx(3) = gca;
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.01, 1, 0.99]);
h=pcolor(Ge);
colormap( linspecer);
xticks([T2/8,T2/4,3*T2/8,T2/2,5*T2/8,T2*3/4,7*T2/8,T2]);
xlim([0,T2+0.01]);
ylabel('Policies');
cb1 = colorbar();
set(cb1,'position',[.93 .41 .015 .22]);
hold on;
drawnow
yh = get(hAx(3),'title') % handle to the label object
p1 = get(yh,'position') % get the current position property
p1(2) = 1.15*p1(2) ;
set(yh,'position',p1); % set the new position
Answers (1)
Ameer Hamza
on 13 Nov 2020
Edited: Ameer Hamza
on 13 Nov 2020
It seems that your first column has NaN values. You can skip the first column in the call to pcolor()
M; % matrix used as input to pcolot
pcolor(M(:,2:end))
2 Comments
Ameer Hamza
on 13 Nov 2020
You are starting xlim from 0. pcolor() starts from 1. Change the line to
xlim([1,T2+0.01]);
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!