필터 지우기
필터 지우기

Modify colorbar in .fig file

조회 수: 10 (최근 30일)
sas0701
sas0701 2012년 2월 23일
편집: S. 2013년 10월 24일
Hello,
Is there anyway to rescale the colors in a figure and hence the colorbar?
eg. Right now colorbar is 0.1 to 0.5 BUT I want the colors in the figure rescaled to 0.1 to 0.7.
Is there anyway to do this without replotting the figure?
Thank you, S

답변 (7개)

Tom
Tom 2012년 2월 23일
Try: caxis([0.1 0.7])
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2012년 2월 23일
+1, You're right, this is probably more what sas0701 is looking for.

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


Sean de Wolski
Sean de Wolski 2012년 2월 23일
figure;
imagesc(magic(20));
h = colorbar;
pause %pause so you can see the change on the next line
set(h,'ylim',[30 60]);
Like this?

sas0701
sas0701 2012년 2월 23일
Hi, Do I have to something special in terms of loading the figure (just opening it up and typing caxis does not work)?
Thanks, S
  댓글 수: 2
Tom
Tom 2012년 2월 23일
I tried it by opening a saved figure which had a color bar on, and it worked for me. But maybe you could try what Sean wrote, though you'll have to find the handle of the color bar yourself:
someone smarter than me might know a quicker way, but to get started you can do H=get(gcf,'children'), and find which one of those has the tag 'Colorbar'
Sean de Wolski
Sean de Wolski 2012년 2월 23일
h = findobj('tag','Colorbar')

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


sas0701
sas0701 2012년 2월 23일
Hi,
I tried both ways.I first open up a saved .fig file
1)caxis does not change anything 2)set(h...) changes colorbar limits but does not rescale figure colors..
Help!
  댓글 수: 3
sas0701
sas0701 2012년 2월 23일
Hi, Is there a way to attach a file here?
Sean de Wolski
Sean de Wolski 2012년 2월 23일
Post the image to a free webhosting site and then use the << url>> tag to poast it in your question. Edit your original question to include the new info:
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

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


sas0701
sas0701 2012년 2월 23일
Hi,
Please see attached file here: http://fileslap.com/9hn/Coh070911fx
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2012년 2월 24일
link not working

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


sas0701
sas0701 2012년 2월 23일
I am trying to modify the CLim in the above saved figure..i.e. without creating a new figure.

sas0701
sas0701 2012년 2월 24일
Hi, Anybody? Want to modify CLim in a saved figure without regenerating it.
Thanks,
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2012년 2월 24일
CLim is the property of an axes; so get the children of the figure, and modify the clim property of them using set()
sas0701
sas0701 2012년 2월 24일
This worked.
Open figure. Manually click on it (for some reason this needs to be done) to select it.
set(gca,'CLim',[a b])
This rescales the colors in the figure and updates the colorbar.
Thank you Sean!

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

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by