//corrected_meanImage和s2_meanImage都是单波段影像
var differenceImage = corrected_meanImage.subtract(s2_meanImage).rename('NDVI_difference');
// 绘制直方图
var histogram = ui.Chart.image.histogram({
image: differenceImage,
region: cities, //区域
scale: 30,
maxPixels: 1e13
}).setOptions({
title: 'NDVI difference pre_obs Histogram', //直方图标题
hAxis: {title: 'NDVI Difference'},//横轴标题
vAxis: {title: 'Frequency'},//纵轴标题
legend: {position: 'none'},
histogram: {
maxBuckets: 20 // 设置箱体数量为30//PS:貌似没有作用
}
});
print(histogram);
结果如下图所示: