html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/pull/5622#issuecomment-1159477493,https://api.github.com/repos/pydata/xarray/issues/5622,1159477493,IC_kwDOAMm_X85FHDj1,14371165,2022-06-18T14:48:36Z,2022-06-18T14:48:36Z,MEMBER,pre-commit.ci autofix,"{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 1, ""eyes"": 0}",,948049609 https://github.com/pydata/xarray/pull/5622#issuecomment-1018993772,https://api.github.com/repos/pydata/xarray/issues/5622,1018993772,IC_kwDOAMm_X848vJxs,14371165,2022-01-22T00:40:23Z,2022-01-22T00:40:23Z,MEMBER,"Line plots aren't completely broken now. The array is being stacked to 1 dim now. Using nan to split the lines at appropriate places. ![image](https://user-images.githubusercontent.com/14371165/150616682-b80be7f7-1c45-4ff1-954e-0ac06c5a08c3.png)
```python ds = xr.tutorial.scatter_example_dataset(seed=42) hue_ = ""y"" x_ = ""y"" size_=""y"" z_ = ""z"" fig = plt.figure() ax = fig.add_subplot(1, 2, 1, projection='3d') ds.A.sel(w=""one"").plot.line(x=x_, z=z_, hue=hue_, linewidth=size_, ax=ax) ax = fig.add_subplot(1, 2, 2, projection='3d') ds.A.sel(w=""one"").plot.scatter(x=x_, z=z_, hue=hue_, markersize=size_, ax=ax) ```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,948049609 https://github.com/pydata/xarray/pull/5622#issuecomment-1008210008,https://api.github.com/repos/pydata/xarray/issues/5622,1008210008,IC_kwDOAMm_X848GBBY,14371165,2022-01-09T01:47:20Z,2022-01-09T01:47:20Z,MEMBER,"Gotten a little sidetracked with line plots for a while now. I'm annoyed that all the primitives are different for each plotting type, e.g Collections, Line2D, list of Line2D, etc. It makes it hard to use similar code paths. So I've been trying out LineCollection a little which behaves very similarly to `ax.scatter`. Being able to use `hue` and `size` the same way as in `scatter` seems like a big improvement to me. In the example below you can clearly see that we have two curves where the hue changes somehow over time. But I'm having trouble understanding how to determine what's supposed to be a line. For example if x and y were 4d arrays how should it be split? scatter uses ravel to get around these hard questions. Maybe you can ravel just certain dimensions? Like if `y(a,b,c,d)` and `x(a, b)` maybe you can * ravel along `a,b` and create a single line * Will this require sorting as unsorted lines usually looks bad? Does it make sense at that point? * new lines will be generated along remaining dims; `c, d`. * How do you label these new lines, since color and linewidth can now be used along lines as well? Using linestyle along `c`? Those are finite though. And what about the `d` dim and possibly other remaining dims? Maybe they should just remain a mystery? You probably could play around with hue or size to see those changes. Not sure how to do that in xarray though. Thoughts, ideas or other examples are appreciated. ![image](https://user-images.githubusercontent.com/14371165/148664742-728222d4-7972-419f-8c79-6f42c3a97b6a.png)
```python import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.dates as mdates import numpy as np from matplotlib.collections import LineCollection import numpy as np np.random.seed(42) dates = np.arange(""2017-01-01"", ""2017-06-20"", dtype=""datetime64[D]"" ) y = np.cumsum(np.random.normal(size=len(dates))) y2 = np.cumsum(np.random.normal(size=len(dates))) c = np.cumsum(np.random.normal(size=len(dates))) c2 = np.cumsum(np.random.normal(size=len(dates))) s = 1 + np.minimum(np.cumsum(np.random.normal(size=len(dates))), 0) s2 = 1 + np.minimum(np.cumsum(np.random.normal(size=len(dates))), 0) fig, ax = plt.subplots() #convert dates to numbers first inxval = mdates.date2num(dates) points = np.array([inxval, y]).T.reshape(-1,1,2) segments = np.concatenate([points[:-1],points[1:]], axis=1) lc = LineCollection(segments, cmap=""plasma"", linewidth=s) lc.set_array(c) p = ax.add_collection(lc) points2 = np.array([inxval, y2]).T.reshape(-1,1,2) segments2 = np.concatenate([points2[:-1],points2[1:]], axis=1) lc2 = LineCollection(segments2, cmap=""plasma"", linewidth=s2) lc2.set_array(c2) p = ax.add_collection(lc2) fig.colorbar(p, ax=ax) ax.xaxis_date() ax.autoscale_view() plt.show() ```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,948049609 https://github.com/pydata/xarray/pull/5622#issuecomment-984071123,https://api.github.com/repos/pydata/xarray/issues/5622,984071123,IC_kwDOAMm_X846p7vT,14371165,2021-12-01T21:29:42Z,2021-12-01T21:40:17Z,MEMBER,"> Not sure if this is too naïve from my side but can you just pass N+1 levels to the function? Pretty much what I did. `[""a"", ""b"", ""c""]` is converted to `[1, 3, 5]`. The discrete colors/levels are bounded by `[(0, 2), (2, 4), (4, 6)]`. This way the ticks will be put nicely in the middle of the discrete color. ![image](https://user-images.githubusercontent.com/14371165/144318390-498fc60c-dbcc-4c15-8b03-1a1b94f1cd6f.png) ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,948049609 https://github.com/pydata/xarray/pull/5622#issuecomment-981065902,https://api.github.com/repos/pydata/xarray/issues/5622,981065902,IC_kwDOAMm_X846eeCu,14371165,2021-11-28T11:11:00Z,2021-11-28T11:11:00Z,MEMBER,"I'm struggling getting categorical colorbars to work nicely: ![image](https://user-images.githubusercontent.com/14371165/143718968-9068fe20-d040-4950-a642-670592928aef.png)
```python import numpy as np import xarray as xr das = [ xr.DataArray( np.random.randn(3, 3, 4, 4, 2), dims=[""x"", ""row"", ""col"", ""hue"", ""size""], coords=[range(k) for k in [3, 3, 4, 4, 2]], ) for _ in [1, 2] ] ds = xr.Dataset({""A"": das[0], ""B"": das[1]}) ds.hue.name = ""huename"" ds.hue.attrs[""units""] = ""hunits"" ds.x.attrs[""units""] = ""xunits"" ds.col.attrs[""units""] = ""colunits"" ds.row.attrs[""units""] = ""rowunits"" ds.A.attrs[""units""] = ""Aunits"" ds.B.attrs[""units""] = ""Bunits"" ds2 = ds.copy() ds2[""hue""] = [""d"", ""a"", ""c"", ""b""] g = ds2.plot.scatter( x=""A"", y=""B"", hue=""hue"", markersize=""size"", col=""col"", add_legend=True, add_colorbar=True, ) ```
My goals are: * 4 colors for 4 categories * ticks should be centered on the color. One of the issues are that https://github.com/pydata/xarray/blob/135a3351bf77a4a55e76a8c60b40852ec10cdd4a/xarray/plot/utils.py#L69 Seems to be focused on contour(f) plots only which leads to the colorbar having N-1 colors all the time. Any ideas how to solve this is appreciated. Related links: * https://stackoverflow.com/questions/14777066/matplotlib-discrete-colorbar * https://gist.github.com/jakevdp/8a992f606899ac24b711 ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,948049609 https://github.com/pydata/xarray/pull/5622#issuecomment-887055377,https://api.github.com/repos/pydata/xarray/issues/5622,887055377,IC_kwDOAMm_X84032QR,14371165,2021-07-26T22:00:14Z,2021-07-26T22:00:14Z,MEMBER,"The scatter tests doesn't seem to make sure x,y values are plotted as expected. I was testing the test cases for other reasons and noticed that the x and values were opposite. You can check the x and y values are returned in the expected order with something like this: ```python fig, ax = plt.subplots(1,1) p = ax.plot([1, 2], [3, 4]) p[0].get_data() Out[12]: (array([1, 2]), array([3, 4])) ``` Something similar can probably be done with hue and size as well so there shouldn't be any need for the tricky display tests.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,948049609 https://github.com/pydata/xarray/pull/5622#issuecomment-886264499,https://api.github.com/repos/pydata/xarray/issues/5622,886264499,IC_kwDOAMm_X84001Kz,14371165,2021-07-25T22:09:37Z,2021-07-25T22:09:37Z,MEMBER,"Good idea to keep the dataarray scatter non-public for now, found quite a few bugs there. :) Turned out a little trickier than expected to get the tests passing, I'll continue pondering this next week. Some thoughts before I forget them: * How important is the argument order for the plotting functions? It's been very difficult getting the line plot and scatter to behave the same because they have completely different order of inputs. Would be easy if we could just force named arguments? * How important are figure legends in facetgrid? Some tests breaks on this now but I'm not sure it's a good idea to change to figlegends instead of legend per plot. * We seem to be lacking tests regarding how the plot should look like. For example an acccidentally inverted plot didn't crash the tests.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,948049609