issues: 98629509
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
98629509 | MDExOlB1bGxSZXF1ZXN0NDE0MjI4NjQ= | 509 | Discrete colormap/colorbar option | 2443309 | closed | 0 | 15 | 2015-08-02T19:17:31Z | 2015-08-06T19:53:17Z | 2015-08-06T16:06:33Z | MEMBER | 0 | pydata/xarray/pulls/509 | 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 DataArrayx = 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 plotsfig, 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
Produces this plot: In the first example, we corrected for this by setting |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/509/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | pull |