Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
201dc2a
Initailize class 2D norm
patniharshit Jun 9, 2017
7217536
Change name of class to BivariateNorm, take normalizer instances sepa…
patniharshit Jun 9, 2017
0178730
Bivariate works with imshow, pcolor, pcolormesh, pcolorfast
patniharshit Jul 3, 2017
575a244
add blank line between bivariate classes
patniharshit Jul 9, 2017
8425637
Add support for bivariate in scatter
patniharshit Jul 9, 2017
4a5831d
Fix missing norm2 in BivaraiteNorm
patniharshit Jul 11, 2017
85df736
Fixed bug in if condition bivariate mapping
patniharshit Jul 12, 2017
8e1bc63
Add autoscale, autoscale_None, scaled methods for BivariateNorm
patniharshit Jul 13, 2017
a9aace3
trying to show ticks and labels on both x and y axis
patniharshit Jul 16, 2017
55a7a68
commented outline code, changed gridspace to show sqaure colorbar
patniharshit Jul 17, 2017
c2eb617
2d colorbar printing now
patniharshit Jul 17, 2017
daef751
Add code for Colorsquare
patniharshit Jul 22, 2017
96af3d3
Modify axis aspect and fraction for colorsquare
patniharshit Jul 22, 2017
9285372
fix failing commits
patniharshit Jul 22, 2017
01b5932
Change PEP8 violations
patniharshit Jul 27, 2017
28288e2
Revert isBivari, remove classic locator
patniharshit Jul 29, 2017
ca2b111
Subclass normalizers from Abstract Base Class
patniharshit Aug 2, 2017
75b4eba
move _ticker function inside update_ticks
patniharshit Aug 2, 2017
bf65847
move _ticker function inside update_ticks
patniharshit Aug 2, 2017
f9dc4b1
remove cmap in imshow and pcolorfast
patniharshit Aug 5, 2017
8a985f0
Defer call to norm and cmap in imshow
patniharshit Aug 7, 2017
8f6928d
Fix bivariate handling with pcolormesh
patniharshit Aug 15, 2017
d54cb44
Make pcolor work with bivariate
patniharshit Aug 16, 2017
4d03552
Do 2D->1D mapping in call method of colormap
patniharshit Aug 20, 2017
2573610
Use list comprehensions to ravel
patniharshit Aug 20, 2017
9228480
Reflect on reviews
patniharshit Aug 21, 2017
5c8dc65
Update docstrings
patniharshit Aug 25, 2017
21ea65f
Add bivariate example
patniharshit Aug 25, 2017
b8d43a9
Treat one as slightly less than one
patniharshit Aug 25, 2017
7681d14
Change conditions for bivar
patniharshit Aug 25, 2017
59f56af
Add image comparison test for bivariate
patniharshit Aug 25, 2017
f98978f
Update is_bivar condition to expect either BivariateNorm or Bivariate…
patniharshit Aug 26, 2017
75a289f
Add line continuation in docstrings
patniharshit Aug 27, 2017
7803974
Debug doc build fail
patniharshit Aug 28, 2017
e40c87b
Add missing symbols in docs
patniharshit Aug 28, 2017
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
Prev Previous commit
Next Next commit
Defer call to norm and cmap in imshow
  • Loading branch information
patniharshit committed Aug 27, 2017
commit 8a985f0400f39fe81834a1187f27e3052f2183f2
5 changes: 0 additions & 5 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5137,11 +5137,6 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
of pixel (0, 0).

"""

temp = np.asarray(X)
if temp.ndim == 3 and isinstance(norm, mcolors.BivariateNorm):
X = norm(temp)

if not self._hold:
self.cla()

Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/axes/_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def subplot_class_factory(axes_class=None):
(SubplotBase, axes_class),
{'_axes_class': axes_class})
_subplot_classes[axes_class] = new_class

return new_class

# This is provided for backward compatibility
Expand Down
34 changes: 23 additions & 11 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ def get_size(self):
if self._A is None:
raise RuntimeError('You must first set the image array')

return self._A.shape[:2]
if isinstance(self.norm, mcolors.BivariateNorm):
imshape = self._A.shape[1:]
else:
imshape = self._A.shape[:2]
return imshape

def set_alpha(self, alpha):
"""
Expand Down Expand Up @@ -300,6 +304,12 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
`trans` is the affine transformation from the image to pixel
space.
"""
if isinstance(self.norm, mcolors.BivariateNorm):
imwidth = A.shape[1]
imheight = A.shape[2]
else:
imwidth = A.shape[0]
imheight = A.shape[1]
if A is None:
raise RuntimeError('You must first set the image '
'array or the image attribute')
Expand All @@ -323,15 +333,15 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
# Flip the input image using a transform. This avoids the
# problem with flipping the array, which results in a copy
# when it is converted to contiguous in the C wrapper
t0 = Affine2D().translate(0, -A.shape[0]).scale(1, -1)
t0 = Affine2D().translate(0, -imwidth).scale(1, -1)
else:
t0 = IdentityTransform()

t0 += (
Affine2D()
.scale(
in_bbox.width / A.shape[1],
in_bbox.height / A.shape[0])
in_bbox.width / imheight,
in_bbox.height / imwidth)
.translate(in_bbox.x0, in_bbox.y0)
+ self.get_transform())

Expand Down Expand Up @@ -362,17 +372,17 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
if A.ndim not in (2, 3):
raise ValueError("Invalid dimensions, got {}".format(A.shape))

if A.ndim == 2:
if not isinstance(self.norm, mcolors.BivariateNorm):
A = self.norm(A)
if A.ndim == 2 or (A.ndim == 3 and
isinstance(self.norm, mcolors.BivariateNorm)):
A = self.norm(A)
if A.dtype.kind == 'f':
# If the image is greyscale, convert to RGBA and
# use the extra channels for resizing the over,
# under, and bad pixels. This is needed because
# Agg's resampler is very aggressive about
# clipping to [0, 1] and we use out-of-bounds
# values to carry the over/under/bad information
rgba = np.empty((A.shape[0], A.shape[1], 4), dtype=A.dtype)
rgba = np.empty((imwidth, imheight, 4), dtype=A.dtype)
rgba[..., 0] = A # normalized data
# this is to work around spurious warnings coming
# out of masked arrays.
Expand Down Expand Up @@ -411,9 +421,10 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,

if not created_rgba_mask:
# Always convert to RGBA, even if only RGB input
isBivari = (A.ndim == 2 and A.shape[0] == 2)
if A.shape[2] == 3:
A = _rgb_to_rgba(A)
elif A.shape[2] != 4:
elif A.shape[2] != 4 and not isBivari:
raise ValueError("Invalid dimensions, got %s" % (A.shape,))

output = np.zeros((out_height, out_width, 4), dtype=A.dtype)
Expand Down Expand Up @@ -596,8 +607,9 @@ def set_data(self, A):
not np.can_cast(self._A.dtype, float, "same_kind")):
raise TypeError("Image data cannot be converted to float")

if not (self._A.ndim == 2
or self._A.ndim == 3 and self._A.shape[-1] in [3, 4]):
isRGB = (self._A.ndim == 3 and self._A.shape[-1] in [3, 4])
isBivari = (self._A.ndim == 3 and self._A.shape[0] == 2)
if not (self._A.ndim == 2 or isRGB or isBivari):
raise TypeError("Invalid dimensions for image data")

self._imcache = None
Expand Down