plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.02k stars 2.54k forks source link

support colormodel in px.imshow #2717

Open emmanuelle opened 4 years ago

emmanuelle commented 4 years ago

I just discovered that go.Image has a colormodel attributes, which makes it possible in particular to support hsl values. It'd be nice to support this in px.imshow as well.

emmanuelle commented 3 years ago

this would mean adding a colormodel attribute in px.imshow, corresponding tests in https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/tests/test_core/test_px/test_imshow.py, and an example in the documentation (which could be inspired by https://scikit-image.org/docs/dev/auto_examples/color_exposure/plot_rgb_to_hsv.html)

liudj2008 commented 3 years ago

@emmanuelle I am interested to work on it.

To be clear, 1) Should the tests be updated? It seems like no tests were written for colormodel. 2) colormodel includes ['rgb', 'rgba', 'rgba256', 'hsl', 'hsla'], should all of these be considered?

Thanks!

emmanuelle commented 3 years ago

Hi @liudj2008 thank you very much :-). My idea was to add a colormodel argument to px.imshow which could be either rgb or hsl; handling transparency can be done automatically depending on the number of channels of the image array, as done in https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/express/_imshow.py#L433

One test could be added to check that the colormodel argument is used in the specification in the plotly Figure. Indeed, there are no tests yet related to colormodel.

liudj2008 commented 3 years ago

Hi @emmanuelle , there are two errors occurred during checks: plotlyjs_dev_build and build-doc. Not sure what happened there. Could you help me take a look? Thanks!

Here is the RP link: https://github.com/plotly/plotly.py/pull/2833