Reputation: 11
I am trying to create a time series image chart for GPP and LAI of a single pixel. The graph looks fine as far as the values are considered. I would like to add a title to both y-axis and have both y-axis have a minimum value of 0. I would post a picture of the graph that I currently have, but stack overflow will not let me.
Here is the script:
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);
Upvotes: 0
Views: 907
Reputation: 11
I answered this by changing one letter. Instead of vAxis, use vAxes! To set a minimum y-axis value for each one just add viewWindow: {min: 0} inside each y-axis.
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);
Upvotes: 1