How can I change colorbar division in Matlab
조회 수: 3 (최근 30일)
이전 댓글 표시
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154310/image.png)
Is there anywway I can change it to 10^1, 10^2 10^3 ... 10^7. Thank you
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154311/image.jpeg)
댓글 수: 2
Björn
2014년 8월 12일
Found one way of doing it here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/152310
채택된 답변
Björn
2014년 8월 13일
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 plot
my_clim=[1e1 1e7];
figure('units', 'normalized', 'outerposition', [0.1 0.1 0.8 0.8]);
% Create a "junk" axes to get the appropriate colorbar
linear_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 plot
set(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.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!