Matlab地理坐标散点图函数geoscatter

4
(4)

今天,带来一个Matlab中,可以在地图上(经纬度地理坐标)绘制标记散点图的函数geoscatter的使用方法,主要用于标记地图上的一些地理位置使用。本文主要讲解geoscatter函数在Matlab中的常见用法、语法说明、散点图标记的颜色大小形状创建、地理散点图底图的创建等基本方法。

Matlab地理坐标散点图函数geoscatter

下面,我们将开始详细的介绍geoscatter函数的语法介绍,实例引用,结果展示。首先,我们给出 Matlab 中关于 geoscatter 函数的帮助文本如下:

>> help geoscatter
--- gscatter 的帮助 ---

 gscatter   Scatter plot with grouping variable
    gscatter(X,Y,G) creates a scatter plot of the vectors X and Y grouped
    by G.  Points with the same value of G are shown with the same color
    and marker.  G is a grouping variable defined as a categorical
    variable, numeric, datetime or duration vector, cell array of strings, 
    or string matrix, and it must have the same number of rows as X and Y.
    Alternatively G can be a cell array of grouping variables (such as 
    {G1 G2 G3}) to group the values in X by each unique combination of 
    grouping variable values. Use the data cursor to read precise values 
    and observation numbers from the plot.
 
    gscatter(X,Y,G,CLR,SYM,SIZ) specifies the colors, markers, and
    size to use.  CLR is either a string of color specifications or
    a three-column matrix of color specifications.  SYM is a string
    of marker specifications.  Type "help plot" for more information.
    For example, if SYM='o+x', the first group will be plotted with a
    circle, the second with plus, and the third with x.  SIZ is a
    marker size to use for all plots.  By default, the marker is '.'.
 
    gscatter(X,Y,G,CLR,SYM,SIZ,DOLEG) lets you control whether legends
    are created.  Set DOLEG to 'on' (default) or 'off'.
 
    gscatter(X,Y,G,CLR,SYM,SIZ,DOLEG,XNAM,YNAM) specifies XNAM and
    YNAM as the names of the X and Y variables.  Each must be a
    character string.  If you omit XNAM and YNAM, gscatter attempts to
    determine the names of the variables passed in as the first and
    second arguments.
 
    H = gscatter(...) returns an array of handles to the objects
    created.
 
    Example:  Scatter plot of car data coded by country.
       load carsmall
       gscatter(Weight, MPG, Origin)

相信各位也看到了,我的Matlab2016中使用的是gscatter函数,而且用法与geoscatter不太一样。因此,最好升级Matlab到2020版本,才可以使用本文中所给出的代码。

以下所有代码及代码运行结果均来自Matlab官方。

常见用法

geoscatter(lat,lon)
geoscatter(lat,lon,A)
geoscatter(lat,lon,A,C)
geoscatter(___,M)
geoscatter(___,'filled')
geoscatter(___,Name,Value)
geoscatter(gx,___)
s = geoscatter(___)

语法说明

geoscatter(lat,lon) 在地理坐标区中向量 lat 和 lon 指定的经纬度位置(以度为单位)显示彩色圆。lat 和 lon 的大小必须相同。

geoscatter(lat,lon,A) 使用 A 指定每个标记的面积(以平方磅为单位)。要以相同的大小绘制所有标记,请将 A 指定为标量。要以不同的大小绘制标记,请将 A 指定为长度与 lat 和 lon 相同的向量。如果未指定 A,则 geoscatter 使用默认大小。

geoscatter(lat,lon,A,C) 使用 C 指定每个标记的颜色。

geoscatter(___,M) 创建散点图,其中 M 指定使用的标记。默认情况下,geoscatter 使用圆作为标记。

geoscatter(___,’filled’) 填充标记。

geoscatter(___,Name,Value) 使用一个或多个 Name,Value 对组参数指定散点图的属性。属性设置适用于所有散点图。

geoscatter(gx,___) 将图形绘制到 gx 指定的地理坐标区中,而不是当前坐标区中。

s = geoscatter(___) 返回 Scatter 对象。创建对象之后,可使用 S 修改其属性。

散点图标记的颜色大小形状创建

设置纬度和经度数据。

lon = (-170:10:170);
lat = 50 * cosd(3*lon);

定义控制每个标记面积的数据。

A = 101 + 100*(sind(2*lon));

定义控制每个标记颜色的数据。

C = cosd(4*lon);

在地理散点图上绘制数据,指定标记的大小数据和颜色数据。将标记指定为三角形,而不是默认的圆形。

geoscatter(lat,lon,A,C,'^')
Matlab地理坐标散点图函数geoscatter

地理散点图底图的创建

设置纬度和经度数据。

lon = (-170:10:170);
lat = 50 * cosd(3*lon);

定义控制每个标记面积的数据。

A = 101 + 100*(sind(2*lon));

定义控制每个标记颜色的数据。

C = cosd(4*lon);

在地理坐标区上创建散点图,指定标记大小数据和颜色数据。该示例将标记指定为三角形,而不是默认的圆形。

geoscatter(lat,lon,A,C,'^')
Matlab地理坐标散点图函数geoscatter

更改地理散点图的底图。

geobasemap colorterrain
Matlab地理坐标散点图函数geoscatter

共计4人评分,平均4

到目前为止还没有投票~

很抱歉,这篇文章对您没有用!

让我们改善这篇文章!

告诉我们我们如何改善这篇文章?

文章目录

转载文章,原文出处:MathWorks官网,由古哥整理发布

如若转载,请注明出处:https://iymark.com/articles/1259.html

(4)
微信公众号
古哥的头像古哥管理团队
上一篇 2020年12月21日 18:55
下一篇 2020年12月23日 19:48

你可能感兴趣的文章

发表回复

登录后才能评论
微信小程序
微信公众号