Skip to content

Shade color #2745

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 34 commits into from
Closed

Shade color #2745

wants to merge 34 commits into from

Conversation

tacaswell
Copy link
Member

code to address #2159

…ken a given color by a given percentage (altered CC to ColorConverter)

r,g,b = hls2rgb(h,l,s)

return r,g,b
Copy link
Member Author

Choose a reason for hiding this comment

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

needs a new line at the end of the file.

@pelson
Copy link
Member

pelson commented Jan 20, 2014

Ok, I've put a lot of comments here. In principle this is fine (I wish we had a "color" class to attach this as a method to, but that is for another day) - I've been rather picky about the PEP8 compliance in this PR, I do apologise, particularly since the file you've modified isn't especially PEP8 compliant in the first place, but we have to start somewhere, right? 😄

Finally, a simple unit test for this would be hugely valuable I think - it doesn't have to be super clever, just a 3 liner to put in a color, lighten it, and check the result.

Thanks @dvreed77 and @tacaswell.


h,l,s = rgb2hls(*rgb)

l *= 1 + float(percent)/100
Copy link
Member

Choose a reason for hiding this comment

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

Consider using np.clip for the clipping part.

@dvreed77
Copy link

Thanks for the comments. I have some newbie questions that you might be able to help out with. I created this function in a separate file and when it was working the way I wanted it to I copied and pasted it into my github forked repository and pushed it.

My question is, how can I test it while its in place of my forked repository since this version of matplotlib isn't the one that its in my python path.

I tried to insert the github version at index 0 in my python path, but get the following error when trying to import tests

~/code/matplotlib/lib/matplotlib/transforms.py in ()
33 import numpy as np
34 from numpy import ma
---> 35 from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
36 update_path_extents)
37 from numpy.linalg import inv

ImportError: No module named _path

I implemented a tests within test_colors.py

@tacaswell
Copy link
Member Author

I don't know it is possible to run the tests in-place (see #2175 )

I would suggest using virtual environments.

The other option is to push your changes to your branch at let travis do the testing for you.

@dvreed77
Copy link

My "test" is a plot that takes a color, lightens and darkens and applies
this to 3 rectangles slightly overlapping to show the variation introduced.
I felt this was satisfactory since the code is mostly for aesthetics.

On Wed, Jan 22, 2014 at 11:59 AM, Thomas A Caswell <notifications@github.com

wrote:

I don't know it is possible to run the tests in-place (see #2175#2175)

I would suggest using virtual environments.

The other option is to push your changes to your branch at let travis do
the testing for you.


Reply to this email directly or view it on GitHubhttps://github.com//pull/2745#issuecomment-33043012
.

@tacaswell
Copy link
Member Author

It would be better to have a test something like test_colors.test_rgb_hsv_round_trip. It is much faster to run and tests just the thing we care about here (which is that colors get transformed correctly).

@tacaswell
Copy link
Member Author

@dvreed77 Any chance of this getting these issues addressed in the near future? We are starting the processes of triaging bugs for 1.4 and would like to get this in.

We also need an entry in the change log and whats_new.rst

@dvreed77
Copy link

dvreed77 commented Mar 1, 2014

I will try, been quite busy lately and was a little stumped the last time I
tried to tackle the testing situation. Will get back to you in a few days.

On Mon, Feb 24, 2014 at 11:47 PM, Thomas A Caswell <notifications@github.com

wrote:

@dvreed77 https://github.com/dvreed77 Any chance of this getting these
issues addressed in the near future? We are starting the processes of
triaging bugs for 1.4 and would like to get this in.

We also need an entry in the change log and whats_new.rst

Reply to this email directly or view it on GitHubhttps://github.com//pull/2745#issuecomment-35974669
.

@tacaswell
Copy link
Member Author

@dvreed77 Any progress on this?

@dvreed77
Copy link

dvreed77 commented Apr 5, 2014

I will work on it this weekend, sorry to be a slacker on this

On Thu, Apr 3, 2014 at 10:23 PM, Thomas A Caswell
notifications@github.comwrote:

@dvreed77 https://github.com/dvreed77 Any progress on this?

Reply to this email directly or view it on GitHubhttps://github.com//pull/2745#issuecomment-39526323
.

@tacaswell
Copy link
Member Author

Punting this to 1.5.

@tacaswell tacaswell modified the milestones: v1.5.x, v1.4.0 May 14, 2014
@tacaswell tacaswell modified the milestones: proposed next point release, next point release Feb 19, 2015
@tacaswell
Copy link
Member Author

ping @dvreed77

@dvreed77
Copy link

@tacaswell working on this right now. Can you advise what you think the test should look like. I having trouble figuring this out.

domspad and others added 21 commits July 16, 2015 23:13
FIX: Implement draw_idle in macOSX backend
MNT: Remove unused code in pdf backend
…ken a given color by a given percentage (altered CC to ColorConverter)
…ken a given color by a given percentage, added modifications noted in PR #2745 which included fixing PEP8 errors and adding a test.
…ken a given color by a given percentage, added modifications noted in PR #2745 which included fixing PEP8 errors and adding a test.
@@ -1,3 +1,4 @@
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Stray merge marker

tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request Jul 16, 2017
…ken a given color by a given percentage, added modifications noted in PR matplotlib#2745 which included fixing PEP8 errors and adding a test.
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request Jul 16, 2017
…ken a given color by a given percentage, added modifications noted in PR matplotlib#2745 which included fixing PEP8 errors and adding a test.
@tacaswell tacaswell mentioned this pull request Jul 16, 2017
7 tasks
@tacaswell
Copy link
Member Author

Closing in favor of #8895

@dvreed77 Sorry this sat for so long. If you are still interested in working on this please do, if not, thank you for your work so far.

@tacaswell tacaswell closed this Jul 16, 2017
jklymak pushed a commit to jklymak/matplotlib that referenced this pull request Dec 12, 2017
…ken a given color by a given percentage, added modifications noted in PR matplotlib#2745 which included fixing PEP8 errors and adding a test.
jklymak pushed a commit to jklymak/matplotlib that referenced this pull request Dec 12, 2017
…ken a given color by a given percentage, added modifications noted in PR matplotlib#2745 which included fixing PEP8 errors and adding a test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants