Hello guys,
im struggling with the following problem, maybe someone can help.
My plot (see the code below) is about the timeseries of a variable and i want to add a linear trend. What i already did is to figure out the necessary parameters a and b.
Is there a toolbox-function to plot a line with just these paramets requiered? Or is creating a vector out of these parameters and plotting this vector a better solution?
Any help is appreciated!
Thanks and cheers,
Tim
import cdstoolbox as ct @ct.application(title='Zonal mean and trend') @ct.output.livefigure() def application(): data = ct.catalogue.retrieve( 'reanalysis-era5-land-monthly-means', { 'variable': '2m_temperature', 'product_type': 'monthly_averaged_reanalysis', 'year': [ '2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012', ], 'month': [ '01','02','03','04','05','06','07','08','09','10','11','12' ], 'time': '00:00', } ) temp = ct.cube.average(data, dim=['lat', 'lon']) a, b, a_std, b_std = ct.stats.trend( temp, slope_units='°C year-1') fig = ct.chart.line(temp, layout_kwargs = { 'title': 'Monthly average temperature', 'xaxis':{ 'title': 'Time [years]', 'range': ['2001-07','2013-06'] }, 'yaxis': { 'title': 'ERA5 2m Air temperature (°C)', 'range': [-10,1] } }, scatter_kwargs = { 'mode': 'lines' } ) return fig |