matlab - Correctly change the labels of my colorbar? -


i have data logarithmic. how plot it:

contourf(x, y, log10(my_data));colorbar; 

now, image looks - colors scaled accordingly value of each point, image colorful. however, values displayed next colorbar wrong- miss base (i.e. have 3 instead of 10^3). tried using caxis suggested here:

cmin = min(my_data(:)); cmax = max(my_data(:)); c = contourf(x, y, log10(my_data));colorbar;caxis([cmin cmax]); 

it helped little bit: values displayed colorbar correct. however:

  1. my image of 1 color if plotted my_data instead of log10(my_data). according documentation, intended effect. how rid of it?
  2. the values on colorbar displayed 100, 200, 400, itd. how can change scientific notation?

edit: souver's idea works. however, original ticks aren't nice powers of 10. new ticks following: 10^-1, 10^-0.5, 10^0, 10^0.5, 10^1, etc. don't want ticks such 10^-0.5, 10^0.5, etc. have new (shorter) list of ticks , labels want:

set(cbar, 'ticklabels', new_labels) 

now labels that: 10^-1, 10^-0, 10^1, 10^2, 10^-1, 10^-0, 10^1, 10^2, etc.

how should deal that?

you want modify ticklabels property create custom label each tick mark. can retrieve current tick locations , create label each one.

cbar = colorbar;  % current location of tick marks ticks = get(cbar, 'ticks');  % create label each tick mark (you can modify these want) labels = arrayfun(@(x)['10^', num2str(x)], ticks, 'uniformoutput', false);  % assign labels colorbar set(cbar, 'ticklabels', labels) 

update

you can manually specify tick locations prior running above code.

ticks = [0 10 100 1000]; set(cbar, 'ticks'); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -