Changing size and position of map colorbar
70 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
KSSV
am 19 Okt. 2016
Bearbeitet: KSSV
am 19 Okt. 2016
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
Siehe auch
Kategorien
Mehr zu Mapping Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!