pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.61k stars 1.08k forks source link

Include a markertype in `Dataset.plot.scatter` #4997

Open tomchor opened 3 years ago

tomchor commented 3 years ago

Pardon me if I've missed something, but from the docs and the issues raised it doesn't seem like anyone has proposed to add a marker type in Dataset.plot.scatter. From the docs it seems that right now you can organize points using hue and marker size. It would be nice to add marker type to the mix, and I imagine that it wouldn't too hard.

The only issue I see is that there are a finite number of marker types by default, but that's no different from the finite number of colors in the default color wheel.

Thoughts?

smartlixx commented 3 years ago

According to matplotlib doc, ax.scatter has an argument marker to set the marker style. This can be done to add a new argument in _dsplot and scatter in xarray, and leave the determination of marker styles to matplotlib. A PR can be made if this is OK.

tomchor commented 3 years ago

This definitely sounds okay by me. I'm trying to figure out on my own how to implement this, but these plotting functions are quite complicated with the decorators and the inferences and all! I haven't been able to make much sense of it unfortunately.

keewis commented 3 years ago

This can be done to add a new argument in _dsplot and scatter in xarray, and leave the determination of marker styles to matplotlib

sure, that sounds good. PRs welcome!

gcaria commented 3 years ago

I started working on this, and quickly ran into the obstacle of not being able to differentiate points according to marker style (at least in a single call to plt.scatter), basically this https://github.com/matplotlib/matplotlib/issues/11155

Setting up several calls to plt.scatter (one for each marker style and related set of points) seems like a terrible idea to me, so I guess adding a marker argument would only make sense if the user wants to do it manually (several Dataset.plot.scatter calls) for the same figure.