altair_pandas icon indicating copy to clipboard operation
altair_pandas copied to clipboard

ENH: scatter plot support for colormap

Open pratapvardhan opened this issue 6 years ago • 5 comments

See: pandas.DataFrame.plot.scatter

df = pd.DataFrame(np.random.rand(50, 4), columns=['a', 'b', 'c', 'd'])
df.plot.scatter(x='a', y='b', c='c', colormap='viridis')

image

If this looks good, I'll update tests.

pratapvardhan avatar Aug 30 '19 14:08 pratapvardhan

Looks good. One concern I have is that the names of matplotlib colormaps do not correspond to the names of vega schemes, but there's not really any easy way around that.

jakevdp avatar Aug 30 '19 15:08 jakevdp

can we for all those params support both strings and alt objects?

Casyfill avatar Aug 30 '19 15:08 Casyfill

can we for all those params support both strings and alt objects?

I'd lean toward no. I think the main benefit of this API is the ability to create charts that basically work on multiple backends. If we start supporting altair-specific extensions of the core API, then that flexibility goes away, and it may not be apparent to users when they have created a chart that will no longer render with one of the other backends.

jakevdp avatar Aug 30 '19 16:08 jakevdp

@jakevdp how would you like to proceed on this?

pratapvardhan avatar Sep 01 '19 14:09 pratapvardhan

Let's go ahead and apply colormap directly to scheme as here. Not a perfect solution, but I think it's the best thing that can be done easily at this point.

First tests and a couple minor changes.

jakevdp avatar Sep 01 '19 15:09 jakevdp