ui.Chart.feature.histogram
ui.Chart.feature.histogram(features, property, maxBuckets, minBucketWidth, maxRaw)
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 中的元素数。
// 加载 PRISM 气候法线图像集合;将图像转换为波段。
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();
// 为美国西部的一个地区制作气候变量的点样本。
var region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14);
var climSamp = normClim.sample(region, 5000);
// 定义图表并将其打印到控制台。
var chart =
ui.Chart.feature//这里柱状图的函数是直接应用的
.histogram({features: climSamp, property: '07_ppt', maxBuckets: 30})
.setOptions({
title: 'July Precipitation Distribution for NW USA',
hAxis: {
title: 'Precipitation (mm)',
titleTextStyle: {italic: false, bold: true}
},
vAxis: {
title: 'Pixel count',
titleTextStyle: {italic: false, bold: true}
},
colors: ['1d6b99'],
legend: {position: 'none'}
});
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')
。
// 导入案例数据资料
var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example');
// 设置图标
var chart =
ui.Chart.feature
.groups({设置组内的信息,
features: ecoregions,
xProperty: 'label',
yProperty: '01_tmean',
seriesProperty: 'warm'
})
.setSeriesNames(['Warm', 'Cold'])
.setChartType('ColumnChart')
.setOptions({
title: 'Average January Temperature by Ecoregion',
hAxis:
{title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
vAxis: {
title: 'Jan temp (°C)',
titleTextStyle: {italic: false, bold: true}
},
bar: {groupWidth: '80%'},
colors: ['cf513e', '1d6b99'],
isStacked: true
});
print(chart);