Create Common Plots Using Map Axes - MATLAB & Simulink - MathWorks Switzerland (2025)

Open Live Script

(Since R2023a)

Map axes objects are a type of axes object, similar to axes objects, geographic axes objects, and polar axes objects. Map axes support several types of plots, including point, line, and polygon plots (geoplot), scatter plots (geoscatter), bubble charts (bubblechart), and comet plots (comet). You can use map axes with many MATLAB graphics functions, including gca, hold, geolimits, title, and legend.

Create Map Axes

Unlike other types of axes, map axes require you to create the map axes object before plotting data into it. You can create a map axes object by using the newmap or mapaxes function.

  • Use newmap when you want to create a map in the default projection or in a specified projection.

  • Use mapaxes when you want advanced control of the map, or when you want to include the map in an app.

Create Point, Line, and Polygon Plots

Display points, lines, and polygons on map axes by using the geoplot function. You can specify geospatial tables, shape objects, or numeric coordinates as input to the geoplot function. When you specify geospatial tables or shape objects, you can plot data in any supported geographic or projected coordinate reference system (CRS).

Set up a new map. By default, map axes use an Equal Earth map projection.

figurenewmap

Read three shapefiles into the workspace. The files contain world land areas, rivers and cities. Then, display the land areas as green polygons, the rivers as blue lines, and the city locations as black points.

land = readgeotable("landareas.shp");rivers = readgeotable("worldrivers.shp");cities = readgeotable("worldcities.shp");geoplot(land,FaceColor=[0.7 0.9 0.5],EdgeColor="none")hold ongeoplot(rivers,Color=[0 0.4470 0.7410])geoplot(cities,"k")

Add a title.

title("World Land Areas, Rivers, and Cities")

Create Common Plots Using Map Axes- MATLAB & Simulink- MathWorks Switzerland (1)

Create Scatter Plots

Display scatter plots on map axes by using the geoscatter function. To use the geoscatter function with map axes, you must specify the coordinates using numeric latitudes and longitudes.

Set up a new map using a projected CRS that is appropriate for Europe. For this example, create the CRS using the EPSG code 3035, which uses a Lambert Azimuthal Equal Area projection method.

figurep = projcrs(3035);newmap(p)

Read a shapefile containing world land areas into the workspace. Provide geographic context for the map by displaying the land areas.

land = readgeotable("landareas.shp");geoplot(land,FaceColor=[0.7 0.7 0.7],EdgeColor=[0.65 0.65 0.65])hold on

Read a shapefile containing the locations of world cities into the workspace. Extract the numeric latitude and longitude coordinates. Then, display the city locations using a scatter plot.

cities = readgeotable("worldcities.shp");lat = cities.Shape.Latitude;lon = cities.Shape.Longitude;geoscatter(lat,lon,"filled")

Adjust the geographic limits. Then, add a title and subtitle.

geolimits([35 72],[-25 45])title("Map of Europe")subtitle(p.ProjectionMethod)

Create Common Plots Using Map Axes- MATLAB & Simulink- MathWorks Switzerland (2)

Create Bubble Charts

Display bubble charts on map axes by using the bubblechart function. To use the bubblechart function with map axes, you must specify the coordinates using numeric latitudes and longitudes.

Load Data

Load into the workspace a shapefile containing tsunami events, including attributes such as the maximum heights and the causes. Extract the latitudes, longitudes, maximum heights, and causes. Replace missing causes with "Unknown Cause".

tsunamis = readgeotable("tsunamis.shp",CoordinateSystemType="geographic");lat = tsunamis.Shape.Latitude;lon = tsunamis.Shape.Longitude;maxheight = tsunamis.Max_Height;c = categorical(tsunamis.Cause);c = fillmissing(c,"constant","Unknown Cause");

Set Up Map

This example adds multiple legends to the bubble chart. To manage the alignment of the legends, use a tiled chart layout.

figuret = tiledlayout(1,1);nexttile

Set up a new map using a projected CRS that is appropriate for Southeast Asia. For this example, create a CRS using the ESRI code 102030, which uses a Lambert Conic Conformal projection method.

p = projcrs(102030,Authority="ESRI");newmap(p)

Read a shapefile containing world land areas into the workspace. Provide geographic context for the map by displaying a subset of the land areas. Avoid including the land areas in the legend by setting the HandleVisibility property to "off".

land = readgeotable("landareas.shp");subland = land([1:2,5:18,20:end],:);geoplot(subland,HandleVisibility="off",FaceColor=[0.7 0.7 0.7],EdgeColor=[0.65 0.65 0.65])hold on

Plot Data

Display the data using a bubble chart. To create a legend that illustrates the tsunami causes, use a separate bubble chart for each cause. Specify the bubble sizes using the maximum heights.

causes = categories(c);numCauses = length(causes);mx = gca; for k = 1:numCauses cause = causes(k); idx = c == cause; bubblechart(mx,lat(idx),lon(idx),maxheight(idx),DisplayName=string(cause))end

Note that, to use the bubblechart function with map axes, you must specify the map axes as the target.

Customize Plot

Customize the plot by changing the bubble sizes, adding legends, changing the geographic limits, and adding a subtitle and title.

Specify the minimum and maximum bubble sizes (in points).

bubblesize([3 30])

Add two legends. Illustrate the bubble colors using a legend, and illustrate the bubble sizes using a bubble legend. Store each legend object by specifying an output argument for the bubblelegend and legend functions. Then, move the legends to the bottom outer tile of the tiled chart layout by setting the Layout.Tile property on each object to "south".

lgd = legend;title(lgd,"Cause")blgd = bubblelegend("Maximum Height (m)");lgd.Layout.Tile = "south";blgd.Layout.Tile = "south";

Change the bubble size limits to reflect the sizes of bubbles in Southeast Asia.

bubblelim([1 50])

Adjust the geographic limits.

geolimits([-20 20],[90 170])

Add a title and subtitle.

title("Tsunamis by Cause and Maximum Height")subtitle(p.ProjectionMethod)

Create Common Plots Using Map Axes- MATLAB & Simulink- MathWorks Switzerland (3)

See Also

Functions

  • newmap | geoplot | geoscatter | bubblechart

Properties

  • MapAxes Properties

Related Topics

  • Customize Appearance of Map Axes
  • Change Projection and Projection Parameters
  • Create Geospatial Tables

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Create Common Plots Using Map Axes- MATLAB & Simulink- MathWorks Switzerland (4)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Create Common Plots Using Map Axes
- MATLAB & Simulink
- MathWorks Switzerland (2025)

FAQs

How to create a map in Matlab? ›

Set up a new map by using the newmap function. By default, map axes objects use an Equal Earth projection centered on the prime meridian and the equator. Display the land areas using the geoplot function. You can use map axes to create maps in any supported projected coordinate reference system (CRS).

How do you create an axis in Matlab? ›

axes( parent , Name,Value ) creates the axes in the figure, panel, or tab specified by parent , instead of in the current figure. ax = axes(___) returns the Axes object created. Use ax to query and modify properties of the Axes object after it is created. For a list of properties, see Axes Properties.

How to plot GPS coordinates in Matlab? ›

geoplot( lat , lon ) plots a line in geographic coordinates. Specify latitude coordinates in degrees using lat , and specify longitude coordinates in degrees using lon . If the current axes is not a geographic or map axes, or if there is no current axes, then the function plots the line in a new geographic axes.

How do you plot on the same axis in Matlab? ›

Combine Plots in Same Axes

By default, new plots clear existing plots and reset axes properties, such as the title. However, you can use the hold on command to combine multiple plots in the same axes. For example, plot two lines and a scatter plot. Then reset the hold state to off.

How to plot a map? ›

Add a place
  1. On your computer, sign in to My Maps.
  2. Open or create a map. A map can have up to 10,000 lines, shapes, or places.
  3. Click Add marker .
  4. Select a layer and click where to put the place. A layer can have 2,000 lines, shapes, or places.
  5. Give your place a name.
  6. Click Save.

How to plot data on a map in MATLAB? ›

Create Geographic Line Plot

Specify the latitude and longitude for each city, then plot the data using the geoplot function. Customize the appearance of the line using the line specification '-*' . Adjust the latitude and longitude limits of the map using geolimits . Change the basemap using the geobasemap function.

How to plot xy axis in MATLAB? ›

plot( X , Y ) creates a 2-D line plot of the data in Y versus the corresponding values in X .
  1. To plot a set of coordinates connected by line segments, specify X and Y as vectors of the same length.
  2. To plot multiple sets of coordinates on the same set of axes, specify at least one of X or Y as a matrix.

How to show axis in plot in MATLAB? ›

plot3( ax ,___) displays the plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes. plot3(___, Name,Value ) specifies Line properties using one or more name-value pair arguments. Specify the properties after all other input arguments.

How to plot a graph from Simulink in MATLAB? ›

From the Simulink Editor, right-click the logging badge for a signal, and select Properties to open the Instrumentation Properties for the signal. Then, click the graphic representation of the Line. From the Instrumentation Properties, you can also select subplots where you want to plot the signal.

Is there a map function in MATLAB? ›

The map function then works on the individual block of data and adds one or more key-value pairs to the intermediate KeyValueStore object using the add or addmulti functions.

How to plot contour maps in MATLAB? ›

To draw the contour lines at specific heights, specify levels as a vector of monotonically increasing values. To draw the contours at one height ( k ), specify levels as a two-element row vector [k k] . contour(___, LineSpec ) specifies the style and color of the contour lines.

How to set axis properties in Matlab? ›

Specify Axis Limits
  1. Set the maximum x-axis limit to 0 and the minimum y-axis limit to -1. ...
  2. Control the direction of increasing values along the x-axis and y-axis by setting the XDir and YDir properties of the Axes object. ...
  3. By default, the x-axis and y-axis appear along the outer bounds of the axes.

How do you make two axis in Matlab? ›

Create axes with a y-axis on both the left and right sides. Plot a set of data against the left y-axis. Then, use yyaxis right to activate the right side so that subsequent graphics functions target it. Plot a second set of data against the right y-axis and set the limits for the right y-axis.

How to plot two different arrays in matlab? ›

Direct link to this answer
  1. DP_in_flow_time = interp1(DP_time, DP, flow_time, 'linear','extrap'); % Expresses 'DP' As A Function Of 'flow_time'
  2. figure.
  3. plot(flow_time, flow)
  4. hold on.
  5. plot(flow_time, DP_in_flow_time)
  6. hold off.
Jan 28, 2019

How do I create my own map? ›

Create a map
  1. On your computer, sign in to My Maps.
  2. Click Create a new map.
  3. Go to the top left and click "Untitled map."
  4. Give your map a name and description.

How do you create an array map? ›

map() method. .map() creates an array from calling a specific function on each item in the parent array. .map() is a non-mutating method that creates a new js array, as opposed to mutating methods, which only make changes to the calling array. This method can have many uses when working with arrays.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Rob Wisoky

Last Updated:

Views: 5441

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Rob Wisoky

Birthday: 1994-09-30

Address: 5789 Michel Vista, West Domenic, OR 80464-9452

Phone: +97313824072371

Job: Education Orchestrator

Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.