pull_requests: 41422864
This data as json
id | node_id | number | state | locked | title | user | body | created_at | updated_at | closed_at | merged_at | merge_commit_sha | assignee | milestone | draft | head | base | author_association | auto_merge | repo | url | merged_by |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
41422864 | MDExOlB1bGxSZXF1ZXN0NDE0MjI4NjQ= | 509 | closed | 0 | Discrete colormap/colorbar option | 2443309 | This PR adds a discrete colormap / colorbar option to xray plots. closes #500 ``` python import matplotlib.pyplot as plt import numpy as np import xray # sample DataArray x = np.arange(start=0, stop=10, step=2) y = np.arange(start=9, stop=-7, step=-3) xy = np.dstack(np.meshgrid(x, y)) distance = np.linalg.norm(xy, axis=2) distance = xray.DataArray(distance, list(zip(('y', 'x'), (y, x)))) # Sample plots fig, axes = plt.subplots(2, 2, figsize=(8, 8), sharex=True, sharey=True) distance.plot(ax=axes[0, 0]) axes[0, 0].set_title('Default') distance.plot(vmin=0, vmax=12, levels=6, ax=axes[1, 0]) axes[1, 0].set_title('Setting with integer levels') distance.plot(levels=[1, 2, 4, 5, 7, 9], extend='both', cmap='Spectral', ax=axes[0, 1]) axes[0, 1].set_title('Setting with list of levels') flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"] distance.plot(levels=[1, 2, 4, 5, 7], cmap=flatui, extend='both', ax=axes[1, 1]) axes[1, 1].set_title('Using custom list of colors') ``` Produces these plots:  There are potential issues that I'd still like to look into a bit further. 1. Does discretizing `cmap` impact the `contour` and `contourf` plot types? We may need some logic to only discretize when the plot type is `imshow` or `pcolormesh`. 2. It is possible, in some cases, to end up masking out values equal to `vmax`: ``` python distance.plot(levels=6) ``` Produces this plot:  In the first example, we corrected for this by setting `extend='max'`. | 2015-08-02T19:17:31Z | 2015-08-06T19:53:17Z | 2015-08-06T16:06:33Z | 2015-08-06T16:06:33Z | 9edb6b0f5989431554b8dbf2e2758e2993c0faf1 | 0 | 1d60752d0ea977cea19a72ca30879a0f0bdfaf64 | 43489589958b2a7604e738c99f0b601b9601bef6 | MEMBER | 13221727 | https://github.com/pydata/xarray/pull/509 |
Links from other tables
- 1 row from pull_requests_id in labels_pull_requests