Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

2D Normalization & Colormapping for ScalerMappables #8738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 35 commits into from
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
Change name of class to BivariateNorm, take normalizer instances sepa…
…rately
  • Loading branch information
patniharshit committed Aug 27, 2017
commit 72175362833539a029cbc398f0d145f6695f8a9b
32 changes: 17 additions & 15 deletions 32 lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1349,21 +1349,27 @@ def __call__(self, value, clip=None):
def inverse(self, value):
return value

class Norm2d:
class BivariateNorm:
"""
Normalize a list of two values corresponding to two 1D normalizers
"""
def __init__(self, norm_instances=None):
def __init__(self, norm1=None, norm2=None):
"""
Parameters
----------
norm_instances :
A list of length two having instances of 1D normalizers
norm1 :
An instance of 1D normalizers
norm2 :
An instance of 1D normalizers
"""
if norm_instances is None:
self.norm_instances = [Normalize(), Normalize()]
if norm1 is None:
self.norm1 = Normalize()
else:
self.norm_instances = norm_instances
self.norm1 = norm1
if norm2 is None:
self.norm2 = Normalize()
else:
self.norm2 = norm2

def __call__(self, values, clip=None):
"""
Expand All @@ -1381,13 +1387,11 @@ def __call__(self, values, clip=None):
A list of two normalized values according to corresponding 1D
normalizers.
"""
norm_one, norm_two = self.norm_instances

if clip is None:
clip = [norm_one.clip, norm_two.clip]
clip = [self.norm1.clip, self.norm2.clip]

return [norm_one(values[0], clip=clip[0]),
norm_two(values[1], clip=clip[1])]
return [self.norm1(values[0], clip=clip[0]),
self.norm2(values[1], clip=clip[1])]

def inverse(self, values):
"""
Expand All @@ -1400,9 +1404,7 @@ def inverse(self, values):
-------
A list of two unnormalized values
"""
norm_one, norm_two = self.norm_instances

return [norm_one.inverse(values[0]), norm_two.inverse(values[1])]
return [self.norm1.inverse(values[0]), self.norm.inverse(values[1])]

def rgb_to_hsv(arr):
"""
Expand Down
18 changes: 10 additions & 8 deletions 18 lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,30 +273,32 @@ def _mask_tester(norm_instance, vals):
assert_array_equal(masked_array.mask, norm_instance(masked_array).mask)

@pytest.mark.parametrize(
'norm_instances, values, expected, clip', [
'norm1, norm2, values, expected, clip', [
(
None,
None,
[[0.2, 0.4, 0.5], [5, 7, 9, 10]],
[[0, 0.666667, 1], [0, 0.4, 0.8, 1]],
None
),
(
[mcolors.LogNorm(clip=True, vmax=5), mcolors.Normalize()],
mcolors.LogNorm(clip=True, vmax=5),
None,
[[1, 6], [5, 7, 9, 10]],
[[0, 1.0], [0, 0.4, 0.8, 1]],
None
),
(
[mcolors.PowerNorm(2, vmin=0, vmax=8, clip=None),
mcolors.PowerNorm(2, vmin=2, vmax=8, clip=True)],
mcolors.PowerNorm(2, vmin=0, vmax=8, clip=None),
mcolors.PowerNorm(2, vmin=2, vmax=8, clip=True),
[np.array([-0.5, 0, 2, 4, 8], dtype=float),
np.array([-0.5, 0, 1, 8, 16], dtype=float)],
[[0, 0, 1/16, 1/4, 1], [0, 0, 0, 1, 1]],
None
),
(
[mcolors.SymLogNorm(3, vmin=-30, vmax=5, linscale=1.2),
mcolors.PowerNorm(2, vmin=2, vmax=8, clip=False)],
mcolors.SymLogNorm(3, vmin=-30, vmax=5, linscale=1.2),
mcolors.PowerNorm(2, vmin=2, vmax=8, clip=False),
[np.array([-30, -1, 2, 6], dtype=float),
np.array([-0.5, 0, 1, 8, 16], dtype=float)],
[[0., 0.53980074, 0.826991, 1.02758204], [0, 0, 0, 1, 1]],
Expand All @@ -309,8 +311,8 @@ def _mask_tester(norm_instance, vals):
'SymLogNorm_and_PowerNorm_clip_in_call'
]
)
def test_norm2d(norm_instances, values, expected, clip):
norm = mcolors.Norm2d(norm_instances=norm_instances)
def test_BivariateNorm(norm1, norm2, values, expected, clip):
norm = mcolors.BivariateNorm(norm1=norm1, norm2=norm2)
ans1, ans2 = norm(values=values, clip=clip)
assert_array_almost_equal(ans1, expected[0])
assert_array_almost_equal(ans2, expected[1])
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.