molsysmt.thirds.nglview.set_color_by_value#
- molsysmt.thirds.nglview.set_color_by_value(view, values, element='group', selection='all', cmap='bwr_r', min_value=None, mid_value=None, max_value=None, representation='cartoon', syntax='MolSysMT')[source]#
Adding a new representation colored by a color scale.
A new representation can be added to an NGL view (NGLWidget) with elements colored by a list of values and a color map.
- Parameters:
view (nglview.NGLWidget) – A view of the molecular system as an nglview.NGLWidget native object.
values (list, tuple or numpy.ndarray) – List of values or magnitudes corresponding to each element to be encoded as a color.
element (str, default='group') – Element to be colored according to its value in the input argument values.
selection (str, list, tuple or numpy.ndarray, default='all') – Selection over which this method applies. The selection can be given by a list, tuple or numpy array of integers (0-based), or by means of a string following any of the selection syntax parsable by MolSysMT (see:
molsysmt.select()
).cmap (str, matplotlib.colors.LinearSegmentedColormap, default:'rwb') – The name of the matplotlib colormap or a LineraSegemendedColormap native Python object of the MatPlotLib library.
min_value (float, Quantity, default='None') – Minimum value of the color scale. By default (‘None’), the minimum of the input argument values is taken.
mid_value (float, Quantity, default='None') – Middle value of the color scale. By default (‘None’), the center between of the range [min_value, max_value] is taken.
max_value (float, Quantity, default='None') – Maximum value of the color scale. By default (‘None’), the maximum of the input argument values is taken.
representation (str, default='cartoon') – Representation type supported by NGLView: ‘cartoon’, ‘licorice’, ‘surface’, ‘ball_and_stick’…
syntax (str, default='MolSysMT') – Syntaxis used in the argument selection (in case it is a string). The current options supported by MolSysMt can be found in section XXX (see:
molsysmt.basic.select()
).
- Returns:
The method modifies an nglview.NGLWidget object including the new representation.
- Return type:
None
Examples
>>> import molsysmt as msm >>> from matplotlib.pyplot import colormaps >>> molecular_system = msm.convert('181L', selection='molecule_type=="protein"') >>> charge_residues = msm.physchem.charge(molecular_system, element='group', definition='physical_pH7')  >>> view = msm.view(molecular_system) >>> view.clear() >>> msm.thirds.nglview.color_by_value(view, charge_residues) >>> view
See also
Notes
Have a look to the `YYY`_.