Closed frchalaoux closed 7 years ago
Did you have a look at http://gromacswrapper.readthedocs.io/en/latest/gromacs/core/fileformats/xvg.html#plotting ? See also decimate().
If the docs are still unclear just ping me again.
For decimate():
a
is the array that you are coarsening. maxpoints
determines how many values the coarsened array will have (it is one of the kwargs)Under the hood it uses numkit.timeseries - Coarse graining time series.
From orbeckst: a is the array that you are coarsening
In my case I want to obtain a simple average curve of my pressure along the time (mean or smooth), so should 'a' be the pressure column from the xvg file, i.e columns[1] ? Have you an example of decimate_mean or smooth method with an 'a' argument ?
If you just want to plot, use xvg.plot()
with method
and maxpoints
(using the example):
xvg.plot(columns=[0,1], method="mean", maxpoints=100) # bin-averaged data (100 bins)
xvg.plot(columns=[0,1], maxpoints=None, alpha=0.1) # all data, light gray
The xvg.decimate()
method itself takes a 1D or 2D array as input. A 1D array is turned into a 2D array where the first column is just the index. If you want to use it with the data in the xvg you could do something like:
time_pressure = xvg.array[[0, 1]] # select column 0 as time and column 1 as P
time_pressure_coarse = xvg.decimate("mean", time_pressure, maxpoints=1000)
should 'a' be the pressure column from the xvg file, i.e columns[1]
It can be just the data but if this was a time series you probably want to include the independent variable (time) as well as the 0-th column as in my example, i.e. columns [0, 1].
Thanks a lot Oliver, I sleept happy last tonight, It works perfectly. Yours examples and explanations should be introduced in the doc, they will help newbies with your very rich API. I'dont close the thread cause xvg.plot(columns=[0,1], method="mean", maxpoints=100) works well but I have to investigate decimate now. I run everything in Jupyter and it's really fine.
decimate is ok for me, I can produce arrays that I can manipulate then plot with xvg.plot. Usefull.
Can someone show me how to add a label or a legend to a xvg plot object ? I can't find how to pass **kwargs to xvg.plot() method.
It works now for example to add a label:
pressure.plot(label="Pressure") plt.legend(loc='upper left') plt.show()
I close until ...
Hi,
I don't understand what are the 'a' and kwargs arguments of decimate_mean. Have you an real example how to use decimate_mean(a, maxpoints, kwargs) ?
Cheers, François-Régis Chalaoux.