schrodinger.application.matsci.plotwidgets module

Contains widgets and functionality that are useful for plotting.

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.plotwidgets.greyColorMap(total_iterations, reverse=False)
Matplotlib color map customized for a frame’s figure

with various shades of grey.

Parameters
  • total_iterations (int) – The total number of iterations

  • reverse (bool) – True if brightness of plot needs to increase with increase in iteration number

class schrodinger.application.matsci.plotwidgets.SideHistogram(figure, x_label, y_label='Frequency', x_start=0.6, x_end=0.9, y_start=0.2, y_end=0.9, color='c', face_color='white', fontsize='small', title=None, subplot_pos=None, flip_ylabel=False)

Bases: object

Class to setup a side histogram plot in the passed figure.

__init__(figure, x_label, y_label='Frequency', x_start=0.6, x_end=0.9, y_start=0.2, y_end=0.9, color='c', face_color='white', fontsize='small', title=None, subplot_pos=None, flip_ylabel=False)

Setup an additional axes on the right half of the canvas.

Parameters
  • figure (matplotlib.figure.Figure) – add histogram plot to this figure

  • x_label (str) – name for the x-axis label

  • y_label (str) – name for the y-axis label

  • x_start (float) – relative x-coordinate on the figure where the plot should start from

  • x_end (float) – relative x-coordinate on the figure where the plot should end

  • y_start (float) – relative y-coordinate on the figure where the plot should start from

  • y_end (float) – relative x-coordinate on the figure where the plot should end

  • color (str) – color of the bar of the histogram

  • face_color (str) – bg color of the plot

  • fontsize (int) – font size for the lables

  • title (str) – title for the plot

  • subplot_pos (int) – A three digit integer, where the first digit is the number of rows, the second the number of columns, and the third the index of the current subplot. Index goes left to right, followed but top to bottom. Hence in a 4 grid, top-left is 1, top-right is 2 bottom left is 3 and bottom right is 4. Subplot overrides x_start, y_start, x_end, and y_end.

  • flip_ylabel (bool) – If True will move tics and labels of y-axis to right instead of left. In case of False, it won’t

replot(data, bins=10)

Remove previous histogram (if exists), plot a new one, and force the canvas to draw.

Parameters
  • data (list) – list of data to plot histogram

  • bins (int) – number of bins for the histogram

reset()

Reset Histogram plot.

class schrodinger.application.matsci.plotwidgets.SliderchartVLPlot(**kwargs)

Bases: schrodinger.application.bioluminate.sliderchart.SliderPlot

Overide the SliderPlot class in sliderchart to provide vertical slide bars and significant figure round.

__init__(**kwargs)

See the parent class for documentation

setVsliderPosition(slider_id, value)

Set the position of vertical sliders.

Parameters
  • slider_id (int) – 0 means the left slider; 1 means the right one

  • value (float) – The new x value to attempt to place the slider at

Return type

float

Returns

final slider position, corrected by x range and the other slider

updateSlider(slider_idx, fit_edit=None, value=None, draw=True)

Change the slider to the user typed position, read this new position, and set the widget to this new position. At least one of value and fit_edit must be provided, and only read fit_edit when value is not provided.

Parameters
  • fit_edit (The text of this widget defines one fitting boundary, and the text may be changed according to the newly adjusted boundary.) – swidgets.EditWithFocusOutEvent or None

  • slider_idx (0 --> left vertical slider; 1 --> right vertical slider;) – int (0 or 1)

  • value (set slider to value position, if not None) – float

  • draw (force the canvas to draw) – bool

Return type

float

Returns

left or right slider position

getVSliderIndexes()

Get the data indexes of the left and right vertical sliders. Requires that the x data is sorted ascending.

Return type

(int, int) or (None, None)

Returns

The data indexes of the left and right vertical sliders, or None, None if the sliders are outside the data range

removeSliders(draw=True)

Remove vertical and horizontal sliders from the chart

Parameters

draw (bool) – Whether canvas should be redrawn

class schrodinger.application.matsci.plotwidgets.SliderchartVLFitStdPlot(legend_loc='upper right', fit_linestyle='dashed', fit_linecolor='red', fit_linewidth=2.0, data_label='Data', std_label='Std Dev', fit_label='Fitting', layout=None, **kwargs)

Bases: schrodinger.application.matsci.plotwidgets.SliderchartVLPlot

Inherits the SliderchartVLPlot class. Provides line fitting and std plotting.

__init__(legend_loc='upper right', fit_linestyle='dashed', fit_linecolor='red', fit_linewidth=2.0, data_label='Data', std_label='Std Dev', fit_label='Fitting', layout=None, **kwargs)

See the parent class for documentation

Parameters
  • legend_loc (str) – the location of the legend

  • fit_linestyle (str) – style of the fitted line

  • fit_linecolor (str) – color of the fitted line

  • fit_linewidth (float) – linewidth of the fitted line

  • data_label (str) – legend label for data

  • std_label (str) – legend label for standard deviation

  • fit_label (float) – legend label for fitting line

  • layout (QLayout) – layout to place the SliderchartVLFitStdPlot in

reset()

Reset the labels, title, and plot.

replot(fit_only=False, *args, **kwargs)

See the parent class for documentation

Parameters

fit_only (bool) – if True, only update the fitted line.

Return type

namedtuple

Returns

fitting parameters

updateLegend()

Update legend according to the plotted lines.

plotFitting()

To be overwritten in child class.

plotYSTd(color='green', alpha=0.5)

Plot standard deviation as area.

Parameters
  • color (str) – area color

  • alpha (float) – set area transparent

variationChanged(variation_edit, upper_tau_edit, min_data_num=10)

Response to the variation widget change. Move the upper slider so that the data between the two slider bars have coefficient of variation smaller than the variation widget value.

Parameters
  • variation_edit (The text of this widget defines the coefficient of variation.) – swidgets.EditWithFocusOutEvent

  • upper_tau_edit (The text of this widget defines upper fitting boundary) – swidgets.EditWithFocusOutEvent

  • min_data_num (The minimum number of data points in the fitting range) – int

Raises

ValueError – not enough data available

setXYYStd(xvals, yvals, ystd=None, x_range=None, y_range=None, replot=True)

Set the X values, Y values, and Y standard deviation of the plot.

Parameters
  • xvals (list) – the x values to plot

  • yvals (list) – y series to plot, should be the same length as xvals

  • ystd (list or None) – the standard deviation of y series to plot

  • x_range (tuple or None) – (min, max) values for the X-axis, default is to show all values

  • y_range (tuple or None) – (min, max) values for the Y-axis, default is to show all values

  • replot (bool) – True of plot should be redrawn (default), False if not. False can be used if a subsequent setY is required.

setVarianceEdit(variance_le)

Set the variance text and state.

Parameters

variance_le (The text of this widget shows the coefficient of variation) – swidgets.EditWithFocusOutEvent