![]() With some of the sample data you provided in the comments, this produces: stat.py 20 %s', files) w l lw 3*LINE_WIDTH lc rgb 'red' t 'average' GetLabel(fname)=system(sprintf('echo "%s" | gawk -F"-" "BEGIN"', fname))įor filename u 3:4 w l lw LINE_WIDTH t getLabel(filename), \ #construct a "pretty" label from the file name #get all csv files in current directory as a space-delimited string Now, in Gnuplot, we can invoke this script (lets say that it is stored in the current working directory as stat.py) externally and plot it together with the individual files: set terminal pngcairo enhanced ![]() Stat, bin_edges, _ = binned_statistic(data, data, 'mean', bins = num_of_bins, range = None)įor val, (lb, ub) in zip(stat, zip(bin_edges, bin_edges)): The required number of bins is passed as first argument, while the remaining arguments are interpreted as csv files for processing: #!/usr/bin/env python To this end, one might prepare a short Python script (which implements the steps outlined above) based on theīinned_statistic function provided by the scipy toolkit. divide the x-range into M bins and calculate the average of the y-values that fall into each of the bins.load all the csv files in the current directory.In my opinion, it would be much more practical to delegate this processing task to something more appropriate.Īs an example, let's say that the strategy would indeed be: If this is the case, then Gnuplot is unfortunately not the proper tool for this task. I have to admit that it's not completely clear to me what exactly you want to achieve, nevertheless I have also the feeling that, as mentioned by in the comments, you are trying to do some kind of binned statistic on the data. Here you can adjust the binsize binwidth to your needs. "< tail -q -n 4 libjpeg*csv" u (bin($3,binwidth)):5 smooth uniq w l lw 2 Luckily you can do all this from within gnuplot: round(x) = floor(x 0.5)īin(x,binwidth) = binwidth*round(x/binwidth) The choice of the weight involves a trade-off: if the weight is large then the curve will follow the data points more closely, but will likely exhibit oscillations.Īlternatively you can bin the data points in the x direction, and average those data points that fall within the same bin. "< tail -q -n 4 libjpeg*csv" u 3:5:(0.1) smooth acsplines title "acsplines, weight = 0.1" w l lw 2 "< tail -q -n 4 libjpeg*csv" u 3:5:(100) smooth acsplines title "acsplines, weight = 100" w l lw 2, \ For example, you can specify a weight for the acsplines interpolation: plot \ Some of those functions also take additional parameters. You might want to experiment with the various smoothing functions, see help smooth. "< tail -q -n 4 libjpeg*csv" u 3:5 smooth acsplines w l lw 2 You can do this using the smooth option to the plot command.ĭepending on your needs you could draw an interpolation function through your data. If I understand you correctly you want to draw an average line through the data, rather than fitting the data for function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |