MATLAB: How to change colorbar division in Matlab colorbarcolormapfigureimage Currently my colorbar are divided into 1x 10^7, 2 x 10^7 ,…,7 x 10^7. Is there anywway I can change it to 10^1, 10^2 10^3 … 10^7. Thank you Is there anywway I can change it to 10^1, 10^2 10^3 … 10^7. Thank you Best Answer Just change the meshgrid from [X, Y]=meshgrid(x,x) to [X, Y]=meshgrid(x,y) in the second message at http://www.mathworks.com/matlabcentral/newsreader/view_thread/152310.x=(1:1:125);y=(1:1:90);[X,Y]=meshgrid(x,y);data = 1./sqrt((X/10000000).^2 + (Y/10000000).^2);% Define the range of the data that we wish to plotmy_clim=[1e1 1e7];figure('units', 'normalized', 'outerposition', [0.1 0.1 0.8 0.8]);% Create a "junk" axes to get the appropriate colorbarlinear_axes = subplot(1,1,1);linear_plot = pcolor(linear_axes, X ,Y, data);colormap(jet(64)), caxis(my_clim)cbar = colorbar('peer', linear_axes, 'Yscale', 'log');% Now plot the data on a log scale, but keep the colorbar. This works, but% now the colorbar is not associated with the plotset(linear_axes, 'Visible', 'off')log_axes = axes('Position', get(linear_axes, 'Position'));log_plot = pcolor(log_axes, X, Y, log10(data));colormap(jet(64)), caxis(log10(my_clim));Note that this might not be the best way, because the colorbar is not connected to the plot. Related SolutionsMATLAB: YTickLabel in colormap will be shown with some specified value (not show all) Additional code:cb = colorbar('YTick',[1:numcolors],'YTickLabel', num2str([1:numcolors]'), 'YLim', [1 numcolors]); tix=cb.Ticks; cb.Ticks=tix([1 3 5 6]); cb.TickLabels={'1' '3' '5' '6'}; MATLAB: Changing the number format of colorbar values In R2014b or later, colorbar objects have a http://www.mathworks.com/help/matlab/ref/colorbar-properties.html TickLabels property and also a TickLabelInterpreter. So you could for example,cb = colorbar();set(cb, 'Ticks', [10^7, 2.5*10^7, 5*10^7, 7.5*10^7, 10^8], 'TickLabels', {'10^7', '2.5 x 10^7', '5 x 10^7', '7.5 x 10^7', '10^8'}, 'Interpreter', 'tex') Related QuestionCustom colormap with missing colorsWhy does the colorbar look like thisHow to make the ticks in the colorbar appear at the center of each color in MATLAB 7.0 (R14)Does the backgound generated using PCOLOR disappear when overlaying it with a contour plot in MATLAB 7.3 (R2006b)Imagesc hide one axisInterpt 1 is giving me error
Best Answer