Legend and title are not shown
pacho2 opened this issue · comments
Hello,
I am trying to use GromacsWrapper to see attached file (generated by gromacs mindist tool).
I am doing the following (on a plain "python3" session run from the terminal)
>>> import matplotlib.pyplot as plt
>>> xvg=gromacs.formats.XVG(filename="CB_to_P_2.xvg")
>>> print(xvg.array) -> to try to avoid the "lazy loading issue mentioned at https://github.com/Becksteinlab/GromacsWrapper/issues/13#issuecomment-1137771811
[[0.000000e+00 5.000000e-02 1.000000e-01 ... 4.999000e+02 4.999500e+02
5.000000e+02]
[6.871651e-01 7.082978e-01 7.039531e-01 ... 7.500433e-01 6.888657e-01
7.289565e-01]]
>>> print(xvg.names)
['P-r_2_&_CB']
>>> print(xvg.metadata)
{'legend': ['on', 'box on', 'loctype view', '0.78, 0.8', 'length 2']}
>>> plt.show()
>>> xvg.plot()
/usr/lib/python3.11/site-packages/numpy/core/fromnumeric.py:3464: RuntimeWarning: Mean of empty slice.
return _methods._mean(a, axis=axis, dtype=dtype,
/usr/lib/python3.11/site-packages/numpy/core/_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide
ret = ret.dtype.type(ret / rcount)
/usr/lib/python3.11/site-packages/gromacs/fileformats/xvg.py:1085: AutoCorrectionWarning: Plot had 10001 datapoints > maxpoints = 10000; decimated to 10000 regularly spaced points from the histogrammed data with mean_histogrammed_function().
warnings.warn("Plot had %d datapoints > maxpoints = %d; decimated to %d regularly "
<Axes: >
>>> plt.show()
But the opened matplot lib window keeps missing Title and Legend information :-/
Thanks for your help
The XVG class does not use the legend from the file for plotting, sorry. The XVG.plot() function is rather simple. You'll have to use normal matplotlib functions to add your own legends.
OK, thanks for the info