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?

 채택된 답변

Jonathan Campelli
Jonathan Campelli 2015년 4월 15일

7 개 추천

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

댓글 수: 2

Troy Dion
Troy Dion 2017년 8월 3일
Is there a way to make this work with scatter3?
Troy
Bo Wang
Bo Wang 2020년 4월 27일
its a really nice answer to me , thanks !

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Xiaolong
Xiaolong 2020년 3월 26일

1 개 추천

set(gca,'colorscale','log')

댓글 수: 1

Walter Roberson
Walter Roberson 2020년 4월 27일
Note: that was not available at the time the question was originally asked.

댓글을 달려면 로그인하십시오.

카테고리

질문:

Tom
2015년 4월 15일

댓글:

2020년 4월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by