问题
I am a big fan of Gnuplot and I used it all along my studies for various projects.
Lately I wanted to use Gnuplot to chart some time series like weight loss, exercising results, gas consumptions etc.
Therefore I scale the x-axis like
set xdata time
set timefmt "%d.%m %Y"
set format x "%d.%m"
Now I want to use the fit-function to give me a linear fit. My problem is, that I cannot get that to work if the x-axis is time-related.
回答1:
R is probably a better tool for this kind of problem. It is one of most popular languages for data analysis. Plotting is as simple (or simpler) as in gnu plot.
回答2:
Then change the date to a number, for example a number of days starting from the first date, make the fit, and then convert the numbers back again into dates. That way you'll have "regular" x and y data set.
回答3:
You could use another tool to calculate the regression function and plot the output of that. Some possibilities are: R, |stat or the statistical functions of various spreadsheets. This link has a list of free statistics software.
回答4:
Another good alternative to gnuplot is matplotlib. It's a set of Python libraries for reading, manipulating, and graphing points. They have a nice cookbook at scipy.org, and here's the entry for linear regressions.
来源:https://stackoverflow.com/questions/522731/linear-regression-for-time-series-with-gnuplot