PlotPyStack/PlotPy

Colormap: side effect on image axes

Closed this issue · 0 comments

Steps to reproduce:

  1. Create and show an ImageItem object
  2. Change the image data (using the set_data method): the new data array must have a different shape than the initial one
  3. After a call to replot(), the image is shown as expected with the new dimensions
  4. Change the colormap
  5. When refreshed, the image axes are changed (so that the min/max X/Y values match the initial array dimensions)

It is also possible to reproduce the issue by modifying the test plotpy/tests/features/test_image_data_update.py. Simply replace the get_data function by the following (and when running the test, change the colormap):

def get_data() -> np.ndarray:
    """Compute 2D Gaussian data and add a narrower Gaussian on top with a random
    position and amplitude."""
    size = np.random.randint(50, 200)
    dtype = np.uint16
    amp = np.iinfo(dtype).max * 0.3
    data = ptd.gen_2d_gaussian(size, dtype, sigma=10.0, x0=0.0, y0=0.0, amp=amp)
    # Choose a random position: x0, y0 have to be in the range [-10.0, 10.0]
    x0 = np.random.uniform(-10.0, 10.0)
    y0 = np.random.uniform(-10.0, 10.0)
    # Choose a random amplitude: a has to be in the range [0.1, 0.5]
    a = np.random.uniform(0.1, 0.7) * np.iinfo(dtype).max
    # Add the narrower Gaussian on top
    data += ptd.gen_2d_gaussian(size, dtype, sigma=4.0, x0=x0, y0=y0, amp=a)
    return data