XTicklabels don‘t match
Mostrar comentarios más antiguos
I am plotting a matrix using below code.
The XTicklabels are supposed to be labeled per tick, but they only label every second tick.
Does anybody have a solution?
a = [12 16 5 5 5 11 4 4 3 3]; % rock data
b = [1 1 1 1 2 2 2 2 2 4]; % image data
u = union(a,b);
[~,ia] = ismember(a(:),u);
[bb,ib] = ismember(b(:),u);
n = length(u);
c = accumarray([ia(bb),ib(bb)],1,[n n]);
csum=sum(c,2);
d=c./csum;
% plot the results
figure, clf
x=u';
ytmp=flipud(u); % flip y-direction
y=cellfun(@(x) num2str(x),num2cell(ytmp),'UniformOutput',0);
pcolor(d)
colormap jet
colorbar
set(gca,'XTickLabel',num2str(x))
set(gca,'YTickLabel',y)
xlabel('Image code')
ylabel('Facies code')
8 comentarios
Star Strider
el 18 de Oct. de 2018
It works for me as written, labeling the ticks with the appropriate values of ‘x’ (actually ‘ytmp’), in R2018b.
If you are getting different results, post an image, and mention your MATLAB version.
Bruno Luong
el 19 de Oct. de 2018
work just fine R2018b

Bruno Luong
el 21 de Oct. de 2018
"It would be good if somebody could feed this back to Matlab developers."
Any user can submit a BUG report. So you should it if you like.
Florian
el 22 de Oct. de 2018
Bruno Luong
el 22 de Oct. de 2018
But attention: this is not bug see Rik's answer about set Xtick
Rik
el 23 de Oct. de 2018
Did my suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Labels and Styling en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
