Skip to content

titusjan/pgcolorbar

Repository files navigation

PgColorbar

PgColorbar is a color bar (legend) for PyQtGraph image plots. It can serve as a replacement for PyQtGraph's HistogramLUTItem.

demo screen shot

I started this project because I wasn't satisfied with PyQtGraph's HistogramLUTItem class. This had the following two reasons:

  1. There is to direct way to directly match a color in the bar with the corresponding value. In PgColorBar the tick marks are displayed directly next to the corresponding color.
  2. It is not possible to define your own color scale, only the color scales defined in [GradientEditorItem.py](http://www.pyqtgraph.org/documentation/graphicsItems/gradienteditoritem. html) can be used.

Look at the demo.py program to see how to integrate PgColorbar in your own program. For a real life example see Argos. For the collection of color maps use in Argos see CmLib.

Installing PgColorbar

PgColorbar requires PyQtGraph. Click here to see how to install PyQtGraph.

After installing PyQtGraph you can install PgColorbar with Pip as follows:

%> pip install pgcolorbar

After that you should be able to start the demo with:

%> pgcolorbar_demo

Using PgColorbar

The range of the color scale can be manipulated by panning and zooming the color bar as follows:

  • Pan the range: Drag the legend using the left mouse button up or down to move the color range. This changes the intensity of the colorized image.
  • Zoom the range: Drag the legend using the right mouse button, or scroll with the mousewheel when the cursor is above the legend. This makes the extent of the legend larger or smaller and so changes the contrast of the colorized image.
  • Change the range at one side only: Hover the cursor over one of the dashed horizontal lines (located at the edges of the color bar) until it becomes wider and the cursor changes. Then drag the line up or down. The range will change only at that end-point while the other end-point remains the same. Note that the drag lines might be hidden but they still will appear if the cursor hovers above them.
  • Reset the range: Click the middle mouse button (or mouse wheel) while the cursor is above the legend to reset the range of the legend. This uses the image to automatically determine the range.

In the demo program you can also modify the range by setting it in the spin boxes. In addition, the demo allows you to show/hide the histogram and the drag lines.

About

Color bar to use in PyQtGraph plots

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages