error using heat_hcl
Trying to use the cmap method of heat_hcl I get the error:
AttributeError: 'heat_hcl' object has no attribute '_rev'
I guess this attribute is not initialized?
Dear Mr. Simon
Do you have a minimal to reproduce this issue? The following should work:
from colorspace import heat_hcl
pal1 = heat_hcl()
print(pal1(3))
print(pal1(3, rev = True))
I have, however, encountered another small problem where double-reverse will not work:
pal2 = heat_hcl(rev = True)
print(pal2(3))
print(pal2(3, rev = True))
... which gives twice the same series of colors (always 'reversed').
The error occurs using the cmap method of the palette for matplotlib:
from colorspace import heat_hcl
pal = heat_hcl()
pal.cmap()
I guess adding
self._rev = False
to the __init__ method of heat_hcl should do it?
Ok, I see the error occurs when calling
pal.cmap(rev = True)
I have to address this; Not intended to revert the .cmap(), the palette should be reverted instead. Does it work if you use the following:
from colorspace import heat_hcl
pal = heat_hcl(rev = True)
# and then use pal.cmap() from here
I just forked the repo and added this line, it now seems to work, no error, specplot is identical to R's colorspace.
BTW: terrain_hcl() would need the same fix.
I think that this has been addressed. But as the current code is a bit different from what Thorsten proposed, I'm pinging Reto @retostauffer to double check...
Some more digging: I think this was addressed in the PR https://github.com/retostauffer/python-colorspace/pull/4
That is, indeed, fixed. Reversing colors is either done when creating a colorspace palette (using the _rev = True argument) but can also be done later on the matplotlib cmap using e.g., rainbow().cmap().reversed().
Here is a small gist test script with a quick test/example.