【问题标题】:Creating two y-axis for time series pixel analysis using ui.Chart.image.series() in Google Earth Engine在 Google Earth Engine 中使用 ui.Chart.image.series() 为时间序列像素分析创建两个 y 轴
【发布时间】:2021-04-15 05:18:29
【问题描述】:

我正在尝试为单个像素的 GPP 和 LAI 创建时间序列图像图表。就值而言,该图看起来很好。我想为两个 y 轴添加一个标题,并使两个 y 轴的最小值都为 0。我会发布我目前拥有的图表的图片,但堆栈溢出不会让我这样做。

这是脚本:

https://code.earthengine.google.com/18dedf6d2e871cfb9ce1869f15dd0d80

var chart = ui.Chart.image.series({
                                   imageCollection: modisVeg ,
                                   region: tree ,
                                   scale: 500   ,
                                   xProperty: 'system:index'
                                  })
                          .setSeriesNames(['GPP', 'LAI'])
                          .setOptions({
                            title: '[Time-series Analysis (2019)]: Tree Pixel' ,
                            series: {
                                     0: {
                                         targetAxisIndex: 0 ,
                                         type: "line" ,
                                         lineWidth: 5 ,
                                         pointSize: 0 ,
                                         color: "blue" 
                                        } ,
                                     1: {
                                         targetAxisIndex: 1 ,
                                         type: "line" ,
                                         lineWidth: 5 ,
                                         pointSize: 0 ,
                                         color: "green" 
                                        } ,
                                    } ,
                            hAxis: {
                                    title: 'Date' ,
                                    titleTextStyle: { italic: false, bold: true }
                                   } ,
                            vAxis: {
                                    0: {
                                        title: "GPP (g*C / m^2)" ,
                                        baseline: 0 ,
                                        titleTextStyle: { bold: true , color: 'blue' }
                                      } ,
                                    1: {
                                        title: "LAI" ,
                                        baseline: 0  ,
                                        titleTextStyle: { bold: true, color: 'green' }
                                      }
                                   } ,
                            curveType: 'function'
                          });

print(chart);

【问题讨论】:

    标签: google-earth-engine


    【解决方案1】:

    我通过更改一个字母来回答这个问题。代替 vAxis,使用 vAxes!要为每个 y 轴设置最小 y 轴值,只需在每个 y 轴内添加 viewWindow: {min: 0}。

    var chart = ui.Chart.image.series({
                                       imageCollection: modisVeg ,                          // Image collection we want to use for timeseries analysis
                                       region: tree ,                                       // Pixel we want to use
                                       scale: 500   ,                                       // [Spatial Resolution]: 500
                                       xProperty: 'system:time_start'                       // Date 
                                      })
                              .setSeriesNames(['GPP', 'LAI'])
                              .setOptions({
                                title: '[Time-series Analysis (2019) ]: Tree Pixel' ,
                                series: {
                                         0: {
                                             targetAxisIndex: 0 ,
                                             type: "line" ,
                                             lineWidth: 5 ,
                                             pointSize: 0 ,
                                             color: "blue"
                                            } ,
                                         1: {
                                             targetAxisIndex: 1 ,
                                             type: "line" ,
                                             lineWidth: 5 ,
                                             pointSize: 0 ,
                                             color: "green" 
                                            } ,
                                        } ,
                                hAxis: {
                                        title: 'Date' ,
                                        format: "MM" ,
                                        titleTextStyle: { italic: false, bold: true }
                                       } ,
                                vAxes: {
                                        0: {
                                            title: "GPP (g*C / m^2 / day)" ,
                                            baseline: 0 ,
                                            titleTextStyle: { bold: true , color: 'blue' } ,
                                            viewWindow: { min: 0 }
                                          } ,
                                        1: {
                                            title: "LAI" ,
                                            baseline: 0  ,
                                            titleTextStyle: { bold: true, color: 'green' } ,
                                            viewWindow: { min: 0 }
                                          }
                                      } ,
                                curveType: 'function'
                              });
    
    print("[Time-series for GPP (g*C / m^2 / day) and LAI]: " , chart);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多