Changing size and position of map colorbar

조회 수: 70 (최근 30일)
Abdul
Abdul 2016년 10월 19일
댓글: Abdul 2016년 10월 19일
Hi, I want to change the size and position of my map colorbar. When I try to change the size and location of the colorbar, it is distorted in shape, I don't know why. Can anybody kindly help me. Please guide me why the set command distorts the clorbar? The location of the color bar should be 'southoutside'.The code is as under:
clear all,close all,clc
ax = worldmap('world');
load geoid
R = georasterref('RasterSize',[180 360],'Latlim',[-90 90],'Lonlim', [0 360]);
levels = [-70 -40 -20 -10 0 10 20 40 70];
geoshow(geoid, R, 'DisplayType', 'contour','LevelList',levels,'Fill','on','LineColor','black')
coast = load('coast.mat');
geoshow(coast.lat, coast.long, 'Color', 'white', 'LineWidth', 1.5)
cb = contourcbar('peer',ax,'Location','southoutside');
caxis([-110 90])
colormap(hsv)
set(get(cb,'XLabel'),'String','Geoid Undulation in Meters')
a=get(cb); %gets properties of colorbar
a.Position %gets the positon and size of the color bar
set(cb,'Position',[0.10 0.20 0.70 0.05])% To change size

답변 (1개)

KSSV
KSSV 2016년 10월 19일
편집: KSSV 2016년 10월 19일
a.position returns you a 1x4 array. Which represents [left,bottom,width,height]. You can change first two numbers to change the position, change third number for width and fourth for height.
a = a.Position %gets the positon and size of the color bar
set(cb,'Position',[a(1)+dx a(2)+dy w h])% To change size
you adjust dx,dy to move the color bar....adjust w, h for it's size.
Eg:
set(cb,'Position',[a(1) a(2) 0.70 0.03])
places the colorbar at the same position with width 0.7 and height 0.03
  댓글 수: 1
Abdul
Abdul 2016년 10월 19일
Thanks for the answer. Yes,I do the same but it does not work and distorts the color bar. Any other suggestion?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by