Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Fixes
* Resume running test for empty container that has been skipped (PR#190).
* Improved handling of missing or empty data in scatterplot (PR#210)
* Avoid a numpy crash when using a data source of a unicode array (PR#213).
* Fix white gap between image border and image (PR#219).

Release 4.4.1
-------------
Expand Down
13 changes: 9 additions & 4 deletions chaco/image_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ImagePlot(Base2DPlot):

# The interpolation method to use when rendering an image onto the GC.
interpolation = Enum("nearest", "bilinear", "bicubic")

#------------------------------------------------------------------------
# Private traits
#------------------------------------------------------------------------
Expand Down Expand Up @@ -129,7 +129,7 @@ def _compute_cached_image(self, data=None, mapper=None):

The parameter *data* is for subclasses that might not store an RGB(A)
image as the value, but need to compute one to display (colormaps, etc.).

The parameter *mapper* is also for subclasses that might not store an
RGB(A) image as their value, and gives an opportunity to produce the
values only for the visible region, rather than for the whole plot,
Expand All @@ -149,6 +149,11 @@ def _compute_cached_image(self, data=None, mapper=None):
virtual_width = ur_x - ll_x
virtual_height = ur_y - ll_y

# Convert to the coordinates of the graphics context, which expects
# origin to be at the center of a pixel.
ll_x += 0.5
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true for all GraphicsContexts?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empirically, it is true for the GraphicsContextArray. I rooted around the kiva source code to find a definitive answer, but gave up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to try other GCs to be sure that this is the right place to do this adjustment. The different backends can behave differently, albeit unintentionally. We have been fighting these off-by-(one/half) issues for a long time.

ll_y += 0.5

args = self.position \
+ self.bounds \
+ [ll_x, ll_y, virtual_width, virtual_height]
Expand All @@ -172,7 +177,7 @@ def _compute_cached_image(self, data=None, mapper=None):

# Since data is row-major, j1 and j2 go first
data = data[j1:j2, i1:i2]

if mapper is not None:
data = mapper(data)

Expand Down Expand Up @@ -327,4 +332,4 @@ def _index_mapper_changed_fired(self):
def _value_data_changed_fired(self):
self._image_cache_valid = False
self.request_redraw()