cuxfilter icon indicating copy to clipboard operation
cuxfilter copied to clipboard

[FEA] Image Plot

Open jakirkham opened this issue 4 years ago • 7 comments

Is your feature request related to a problem? Please describe.

It would be nice to have a way to plot an image using an array of data (like a CuPy array). For example, here is Bokeh's image plot. Also here are some examples from Matplotlib.

Describe the solution you'd like

Basically something like image or imshow would capture my needs.

It's worth noting that people plotting images usually expect the origin to be in the upper left. For some interesting discussion in a case where a library deviated from this please see issue ( https://github.com/bokeh/bokeh/issues/1666 ). Though it could make sense to have a user configurable origin to smooth over these differences.

Describe alternatives you've considered

Heatmap is close, but not quite what I'm looking for. It results in the image looking less smooth than one would like. That said, it could be a reasonable starting point if the implementations are close.

Additional context

This is mostly above, but would be happy to answer more questions. 🙂

jakirkham avatar Nov 16 '19 03:11 jakirkham

okay, this is certainly possible. It is slightly different than generating a heatmap as it works only with a cudf dataframe with 2 columns as x,y-coordinates and another column as aggregate values.

My assumption is(from the examples you suggest), you would like to generate an image from a (n*n) cupy array by just providing a color palette.

Taking inspiration from the bokeh example, would something like this work for you? :

import cupy, cuxfilter
N = 500
x = cupy.linspace(0, 10, N)
y = cupy.linspace(0, 10, N)
xx, yy = cupy.meshgrid(x, y)
cupy_arr = cupy.sin(xx)*cupy.cos(yy)

cux_df = cuxfilter.DataFrame.from_cupy(cupy_arr)

chart1 = cuxfilter.image(color_palette='Spectral11', origin='bottom-left')
d = cux_df.dashboard([chart1])

chart1.view()

image

AjayThorve avatar Nov 18 '19 19:11 AjayThorve

Thanks @AjayThorve! I think that would do nicely 😀

jakirkham avatar Nov 19 '19 11:11 jakirkham

So I ran this, but got the following error. Am just running from master.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-3a90a8595424> in <module>
----> 1 import cupy, cuxfilter
      2 N = 500
      3 x = cupy.linspace(0, 10, N)
      4 y = cupy.linspace(0, 10, N)
      5 xx, yy = cupy.meshgrid(x, y)

~/cuxfilter/python/cuxfilter/__init__.py in <module>
----> 1 from .dataframe import DataFrame
      2 
      3 from ._version import get_versions
      4 
      5 __version__ = get_versions()["version"]

~/cuxfilter/python/cuxfilter/dataframe.py in <module>
      4 from typing import Type
      5 
----> 6 from .dashboard import DashBoard
      7 from .layouts import single_feature
      8 from .themes import light

~/cuxfilter/python/cuxfilter/dashboard.py in <module>
      5 from panel.io.server import get_server
      6 
----> 7 from .charts.core.core_chart import BaseChart
      8 from .datatile import DataTile
      9 from .layouts import single_feature

~/cuxfilter/python/cuxfilter/charts/__init__.py in <module>
      6 
      7 from .bokeh import bokeh
----> 8 from .cudatashader import cudatashader
      9 from .altair import altair
     10 from .panel_widgets import panel_widgets

~/cuxfilter/python/cuxfilter/charts/cudatashader/__init__.py in <module>
----> 1 from .cudatashader import scatter_geo, scatter, line, heatmap, stacked_lines

~/cuxfilter/python/cuxfilter/charts/cudatashader/cudatashader.py in <module>
----> 1 from . import plots
      2 
      3 
      4 def scatter_geo(
      5     x,

~/cuxfilter/python/cuxfilter/charts/cudatashader/plots.py in <module>
      7 from .custom_extensions import InteractiveImage
      8 
----> 9 import cudatashader as cds
     10 from cudatashader import transfer_functions as tf
     11 from cudatashader.colors import Hot

ModuleNotFoundError: No module named 'cudatashader'

jakirkham avatar Nov 19 '19 17:11 jakirkham

Oh, I am sorry for the misunderstanding, I was just confirming if the syntax was such, would you be fine with it. It's not implemented yet, hopefully soon.

AjayThorve avatar Nov 19 '19 17:11 AjayThorve

Ah ok, sorry, I got really excited to try. Apologies for misreading things. 😅

Yeah I think the syntax is reasonable. Thanks for giving that a go.

It's probably worth taking a look at imshow and matshow to get a better feeling on what the different origin locations are used for.

jakirkham avatar Nov 19 '19 17:11 jakirkham

This issue has been marked rotten due to no recent activity in the past 90d. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

github-actions[bot] avatar Feb 16 '21 16:02 github-actions[bot]

This issue has been marked stale due to no recent activity in the past 30d. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be marked rotten if there is no activity in the next 60d.

github-actions[bot] avatar Feb 16 '21 16:02 github-actions[bot]