After two days and 30 views no one has even commented on my question. Can anyone recommend me ways to improve my question so that others can easier provide me with answers?
Shared colormap for multiple maps using mapping toolbox and tiledlayout function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone
I have two problems with mapping toolbox
- I want to add a shared colormap for multiple maps. I have added the code below and also the desired figure sample which is cropped from a paper and current code output.
- Another problem is that x labels (which are geographical longitudes) overlap each other and I want to control the size of x labels.
Before running the code make sure to download the attached zip file.
Any help would be greatly appreciated.
clc, clear, close all;
% Loading mat files.
load('Border.mat')
% Visualization
tiledlayout(1, 2)
nexttile
% Getting the approprite extent to fit the map in the map frame.
LonLimit = [Border.BoundingBox(1)-0.1 Border.BoundingBox(2)+0.1];
LatLimit = [Border.BoundingBox(3)-0.1 Border.BoundingBox(4)+0.1];
worldmap(LatLimit, LonLimit)
tightmap
% Adding north arrow and customizing it.
northarrow('latitude', 37.8, 'longitude', 51.2, 'ScaleRatio', 0.15)
H = handlem('NorthArrow');
set(H,'FaceColor', [0 0 0], 'EdgeColor', [0 0 0])
geoshow(Border, 'LineWidth', 1.5, 'DisplayType', 'polygon', 'FaceColor', 'w');
% Reading shp files in current directory.
Files = dir('*.shp');
for i = 1:length(Files)
% Extracting tif file names.
FileName = Files(i).name;
% Importing point shapefile containing each station optimized parameters.
Point = shaperead(FileName, 'UseGeoCoords', true);
% Attribute table field names.
FieldNames = fieldnames(Point);
% Maximum and minimum attribute value.
Max = max([Point.(FieldNames{end})]);
Min = min([Point.(FieldNames{end})]);
% Specifying color bar.
ColorBar = flipud(jet);
% Specifying condition.
DensityColors = makesymbolspec('Point', {FieldNames{end}, [Min Max], 'MarkerFaceColor', ColorBar});
geoshow(Point, 'DisplayType', 'point', 'Marker', 'o', 'MarkerSize', 4, 'MarkerEdgeColor', ...
'none', 'SymbolSpec', DensityColors)
caxis([Min Max])
colormap(ColorBar)
C = colorbar;
% Removing suffix.
FileName = split(FileName, '.shp');
FileName = FileName{1};
C.Label.String = [FileName ' [ % ]'];
C.Label.FontSize = 14;
end
% Repeating previous codes to generate another map just for having a ready
% example !!!!!!!!
nexttile
% Getting the approprite extent to fit the map in the map frame.
LonLimit = [Border.BoundingBox(1)-0.1 Border.BoundingBox(2)+0.1];
LatLimit = [Border.BoundingBox(3)-0.1 Border.BoundingBox(4)+0.1];
worldmap(LatLimit, LonLimit)
tightmap
% Adding north arrow and customizing it.
northarrow('latitude', 37.8, 'longitude', 51.2, 'ScaleRatio', 0.15)
H = handlem('NorthArrow');
set(H,'FaceColor', [0 0 0], 'EdgeColor', [0 0 0])
geoshow(Border, 'LineWidth', 1.5, 'DisplayType', 'polygon', 'FaceColor', 'w');
% Reading shp files in current directory.
Files = dir('*.shp');
for i = 1:length(Files)
% Extracting tif file names.
FileName = Files(i).name;
% Importing point shapefile containing each station optimized parameters.
Point = shaperead(FileName, 'UseGeoCoords', true);
% Attribute table field names.
FieldNames = fieldnames(Point);
% Maximum and minimum attribute value.
Max = max([Point.(FieldNames{end})]);
Min = min([Point.(FieldNames{end})]);
% Specifying color bar.
ColorBar = flipud(jet);
% Specifying condition.
DensityColors = makesymbolspec('Point', {FieldNames{end}, [Min Max], 'MarkerFaceColor', ColorBar});
geoshow(Point, 'DisplayType', 'point', 'Marker', 'o', 'MarkerSize', 4, 'MarkerEdgeColor', ...
'none', 'SymbolSpec', DensityColors)
caxis([Min Max])
colormap(ColorBar)
C = colorbar;
% Removing suffix.
FileName = split(FileName, '.shp');
FileName = FileName{1};
C.Label.String = [FileName ' [ % ]'];
C.Label.FontSize = 14;
end
The output :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/628948/image.jpeg)
The desired figure sample :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/628953/image.jpeg)
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!