How to migrate from plotpy V1

This section describes the steps to migrate python code using plotpy V1 to plotpy V2.

Updating the imports

PlotPy V1 to PlotPy V2

The following table gives the equivalence between plotpy V1 and plotpy V2 imports or objects.

For most of them, the change in the module path is the only difference (only the import statement have to be updated in your client code). For others, the third column of this table gives more details about the changes that may be required in your code.

Compatibility table

plotpy v1

plotpy v2

.gui.widgets.interfaces

.interfaces

.gui.widgets.items

.items

.gui.widgets.panels.PanelWidget

.panels.PanelWidget

.gui.widgets.baseplot.PlotItemList

.panels.itemlist.PlotItemList

.gui.widgets.plot

.plot

.gui.widgets.styles

.styles

.gui.widgets.tools

.tools

.gui.widgets.pyplot

.pyplot

.gui.widgets.builder

.builder

.gui.widgets.baseplot.canvas_to_axes

.coords.canvas_to_axes

.gui.widgets.baseplot.axes_to_canvas

.coords.axes_to_canvas

.gui.widgets.events

.events

.gui.widgets.histogram.hist_range_threshold

.lutrange.hist_range_threshold

.gui.widgets.histogram.lut_range_threshold

.lutrange.lut_range_threshold

.gui.widgets.histogram.HistogramItem

.items.histogram.HistogramItem

.gui.widgets.histogram.ContrastAdjustment

.panels.contrastadjustment.ContrastAdjustment

.gui.widgets.io

.io

.gui.widgets.io.eliminate_outliers

removed

.gui.widgets.colormap

.mathutils.colormap

.gui.widgets.debug

removed

.gui.widgets.debug.buttons_to_str

.events.buttons_to_str

.gui.widgets.debug.evt_type_to_str

.events.evt_type_to_str

.gui.widgets.debug.print_event

removed

.gui.widgets.debug.qimage_format

removed

.gui.widgets.debug.qimage_to_str

removed

.gui.widgets.geometry

.mathutils.geometry

.gui.widgets.scaler

.mathutils.scaler

.gui.widgets.qthelpers.exec_image_save_dialog

.widgets.imagefile.exec_image_save_dialog

.gui.widgets.qthelpers.exec_image_open_dialog

.widgets.imagefile.exec_image_open_dialog

.gui.widgets.qthelpers.exec_images_open_dialog

.widgets.imagefile.exec_images_open_dialog

.gui.widgets.qthelpers.mimedata2url

removed

.gui.widgets.fit

.widgets.fit

.gui.widgets.fliprotate

.widgets.fliprotate

.gui.widgets.qtdesigner

.widgets.qtdesigner

.gui.widgets.resizedialog

.widgets.resizedialog

.gui.widgets.rotatecrop

.widgets.rotatecrop

.gui.widgets.items.baseplot.BasePlot.canvas2plotitem

removed

.gui.widgets.items.baseplot.BasePlot.plotitem2canvas

removed

.gui.widgets.items.baseplot.BasePlot.get_plot_names

removed

.gui.widgets.items.baseplot.BasePlot.set_plot_limits_synchronised

removed

.gui.widgets.items.baseplot.BasePlot.update_lut_range

removed

.gui.widgets.items.baseplot.BasePlot.set_full_scale

removed

PlotPy V1 to guidata V3

With the release of PlotPy V2, the DataSet related features have been moved to the guidata package (from where they were originally extracted).

The following table gives the equivalence between PlotPy V1 and guidata V3 imports or objects.

Compatibility table

plotpy v1

guidata v3

.gui.dataitems.*

.dataset.*

.gui.datatypes.*

.dataset.*

.gui.dataset.qtitemwidgets

.dataset.qtitemwidgets

.gui.dataset.qtwidgets

.dataset.qtwidgets

.core.io.hdf5io

.dataset.io.h5fmt

.core.config.userconfigio

.dataset.io.inifmt

.core.config.userconfig

.userconfig

.core.utils.disthelpers

removed

New method for thresholding image item LUTs

The method plotpy.items.BaseImageItem.set_lut_threshold() has been added. It allows to set the percentage of outliers to be clipped from the image histogram values.

This method is available for all image items:

New options added to plot builder

The PlotItemBuilder factory class has been renamed to PlotBuilder, because it provides not only methods for creating plot items, but also methods for creating ready-to-use plots.

New methods for creating ready-to-use plots have been added to the class:

The method PlotBuilder.contours() has been added, in order to create contour curves. It returns a list of plotpy.items.ContourItem objects.

See demo script tests/items/test_contour.py.

The new keyword parameter alpha_function has been added to the methods PlotBuilder.image(), PlotBuilder.xyimage(), PlotBuilder.maskedimage(), PlotBuilder.maskedxyimage(), PlotBuilder.trimage(), PlotBuilder.rgbimage(), and PlotBuilder.quadgrid(). It allows to specify a function to compute the alpha channel of the image from the data values. The supported functions are:

Warning

The alpha_mask parameter has been removed from the methods PlotBuilder.image(), PlotBuilder.xyimage(), PlotBuilder.maskedimage(), PlotBuilder.maskedxyimage(), PlotBuilder.trimage(), PlotBuilder.rgbimage(), and PlotBuilder.quadgrid(). If you were using it, you should replace it by the new alpha_function parameter.