MATLAB Answers

Logarithmic scale for colorbar

조회 수: 140(최근 30일)
Tom
Tom 15 Apr 2015
Commented: Troy Dion 3 Aug 2017
I sometimes require a plot which has a colorbar with a log scale. Previously I did this by setting the 'yscale' property of the underlying colorbar axes, but this no longer works with the new graphics system. Is there a workaround for the new system?

  댓글 수: 0

로그인 to comment.

채택된 답변

Jonathan Campelli
Jonathan Campelli 15 Apr 2015
Hello Tom,
My script plots sample data in logscale using "countourf", and both "YTick" and "YTickLabel" are set in "colorbar" on the last line:
Data=magic(100);
c=[1 10/3 10 100/3 100 1000/3 1000 10000/3 10000];
contourf(log(Data(:,:)),log(c));
colormap(bone); %Color palate named "bone"
caxis(log([c(1) c(length(c))]));
colorbar('FontSize',11,'YTick',log(c),'YTickLabel',c);
If this code does not meet your needs, let me know, and I will develop a more appropriate solution,
Best regards,
Jonathan Campelli

  댓글 수: 1

Troy Dion
Troy Dion 3 Aug 2017
Is there a way to make this work with scatter3?
Troy

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by