Google Earth Engine(GEE)——矢量柱状图和组图

举报
此星光明 发表于 2022/04/16 01:10:20 2022/04/16
【摘要】 ui.Chart.feature.histogram ui.Chart.feature.histogram(features, property, maxBuckets, minBucketWidth, maxRaw) Generates a Chart from a set of fea...

ui.Chart.feature.histogram

ui.Chart.feature.histogram(features, property, maxBucketsminBucketWidthmaxRaw)

Generates a Chart from a set of features. Computes and plots a histogram of the given property.

- X-axis = Histogram buckets (of property value).

- Y-axis = Frequency (i.e. the number of features whose value of property lands within the x-axis bucket bounds).

Returns a chart.

Arguments:

features (Feature|FeatureCollection|List<Feature>):

The features to include in the chart.

property (String):

The name of the property to generate the histogram for.

maxBuckets (Number, optional):

The maximum number of buckets to use when building a histogram; will be rounded up to a power of 2. Not used when the value of property is non-numeric.

minBucketWidth (Number, optional):

The minimum histogram bucket width, or null to allow any power of 2. Not used when property is non-numeric.

maxRaw (Number, optional):

The number of values to accumulate before building the initial histogram. Not used when property is non-numeric.

Returns: ui.Chart

x 轴由选定属性值范围的值箱定义;y 轴是给定 bin 中的元素数。

 

   
  1. // 加载 PRISM 气候法线图像集合;将图像转换为波段。
  2. var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();
  3. // 为美国西部的一个地区制作气候变量的点样本。
  4. var region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14);
  5. var climSamp = normClim.sample(region, 5000);
  6. // 定义图表并将其打印到控制台。
  7. var chart =
  8. ui.Chart.feature//这里柱状图的函数是直接应用的
  9. .histogram({features: climSamp, property: '07_ppt', maxBuckets: 30})
  10. .setOptions({
  11. title: 'July Precipitation Distribution for NW USA',
  12. hAxis: {
  13. title: 'Precipitation (mm)',
  14. titleTextStyle: {italic: false, bold: true}
  15. },
  16. vAxis: {
  17. title: 'Pixel count',
  18. titleTextStyle: {italic: false, bold: true}
  19. },
  20. colors: ['1d6b99'],
  21. legend: {position: 'none'}
  22. });
  23. print(chart);

ui.Chart.feature.groups

ui.Chart.feature.groups(features, xProperty, yProperty, seriesProperty)

从一组特征生成图表。绘制跨要素组的给定属性的值。具有相同 groupProperty 值的要素将被分组并绘制为单个系列。
 

Generates a Chart from a set of features. Plots the value of a given property across groups of features. Features with the same value of groupProperty will be grouped and plotted as a single series.

- X-axis = xProperty values.

- Y-axis = yProperty values.

- Series = Feature groups, by seriesProperty.

Returns a chart.

Arguments:

features (Feature|FeatureCollection|List<Feature>):

The features to include in the chart.

xProperty (String):

Property to be used as the label for each feature on the x-axis.

yProperty (String):

Property to be plotted on the y-axis.

seriesProperty (String):

Property used to determine feature groups. Features with the same value of groupProperty will be plotted as a single series on the chart.

Returns: ui.Chart

 特征沿 x 轴绘制,由选定属性的值标记。系列由给定属性的唯一值集定义的列表示。Y 轴位置由给定属性的值定义。通过将图表类型设置为'ScatterChart'.setChartType('ScatterChart')),可以将此图更改为散点图 。或者,如果时间为x轴的变量,你可能更愿意使用一个折线图: .setChartType('LineChart')


  
  1. // 导入案例数据资料
  2. var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example');
  3. // 设置图标
  4. var chart =
  5. ui.Chart.feature
  6. .groups({设置组内的信息,
  7. features: ecoregions,
  8. xProperty: 'label',
  9. yProperty: '01_tmean',
  10. seriesProperty: 'warm'
  11. })
  12. .setSeriesNames(['Warm', 'Cold'])
  13. .setChartType('ColumnChart')
  14. .setOptions({
  15. title: 'Average January Temperature by Ecoregion',
  16. hAxis:
  17. {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
  18. vAxis: {
  19. title: 'Jan temp (°C)',
  20. titleTextStyle: {italic: false, bold: true}
  21. },
  22. bar: {groupWidth: '80%'},
  23. colors: ['cf513e', '1d6b99'],
  24. isStacked: true
  25. });
  26. print(chart);

文章来源: blog.csdn.net,作者:此星光明2021年博客之星云计算Top3,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_31988139/article/details/119821419

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。