API Method `hclplot()` from Original R Package Missing?
Closed this issue ยท 12 comments
Though the documentation for the original R package says of this python port:
For Python users a beta re-implementation of the full colorspace package in Python 2/Python 3 is also available
I cannot seem to use the hclplot()
function, and searching the codebase here turns up nothing for it either.
Am I missing something? Is it here under some other alias, or is it just missing from this port?
Thanks for the report and apologies for not responding sooner!
Indeed hclplot()
is currently not ported yet. The main reason is that some statistical modeling is used to get the interpolation and extrapolation of HCL coordinates if there is not one coordinate that is exactly fixed. This can be done easily in base R without introducing any additional dependencies but not in Python. Hence we put that on our wishlist for the time being.
Reto @retostauffer, maybe we should flag this issue as an open wishlist item here?
Thanks @zeileis and sorry @avanavana for the late response. As @zeileis wrote, implementing the hclplot()
does require a bit more than just a few lines of code, we've put it on the whishlist
for now, hoping to get back to it in the near future.
@zeileis getting there, tough not easy to implement as I had to/have to re-implement some R functions from base/stats without adding any more dependencies such as e.g., scipy
/statsmodels
(not using it so far). Working on it (devel
branch; wip). Not the very same results as in R, but close (so far only for sequential_hcl
, but) I think we can get it done.
Added hclplot
to the main branch, tough additional testing and adjustments will be required. A few examples can be found here:
- Article Palette Visualization and Assessment: Trajectories in HCL space
- Examples included in the docstring (
hclplot
function man page) - Article Getting started: Palette visualization and assessment
This looks all fantastic, really cool ๐
In the palette_visualization article hclplot
is apparently not imported yet when running hclplot(qualitative_hcl("Dynamic"));
. Hence this throws an error at the moment.
Regarding the comment:
In R, the colors where C > 0 and L < 1 is TRUE are set to NA, but not the
nd
object. Thus, the title contains the Hue range from all the colors including those which got killed by fixup = TRUE.
Bug or feature?
This is a good question. I'm pretty sure that this is oversight. I think it would make more sense to compute the hue range without the dropped hues.
Agree, before we create conflicts: Shall I fix it quickly?
Oh, and one more minor and non-important detail that I noticed: If luminance is on the y-axis then by default only axis labels for 0, 20, 40, 60, 80 are shown but not 100. Maybe this is easy to fix. If not, nevermind.
I'm not working on anything atm, so feel free to go ahead and fix.
- Title: I'll take care of updating R colorspace (but not today).
- Axis labels: Will check it,
matplotlib
default, I assume it can be fixed by adjusting the upper limit by a small amount (e.g.,5%
as R does).
- R: Adjusted the R code (svn).
- Axis labels (Python): Related to the R fixes, choosing y/x-limits on "valid colors only", thus the upper limit was 99 (not 100). Adjusted that by rounding (floor/ceil) to the next 2.5 interval. For diverging palettes the x-axis is now also only showing positive values on the x-axis for the 'left hand side'.
- Error in article: Missing imports, fixed.
I am closing this issue for now, the hclplot()
has been implemented for the different objects and released with 0.4.4
just now.
- Some examples: https://retostauffer.github.io/python-colorspace/articles/palette_visualization.html
- Function reference: https://retostauffer.github.io/python-colorspace/man/colorspace.hclplot.hclplot.html (w/ examples)
- Other objects also have
.hclplot()
methods which can be used. Exemplarily:diverging_hcl()
,palette
, and allcolorobjects
(e.g.,CIELUV
.
Please open a new issue in case problems occur or additional features are needed.