Skip to content

Commit

Permalink
Merge pull request #63 from desihub/plot_updates
Browse files Browse the repository at this point in the history
Works like a charm -- thank you.
  • Loading branch information
moustakas authored Apr 6, 2017
2 parents 9b2df14 + 7db6b01 commit 0f022fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Change Log

.. _basemap: http://matplotlib.org/basemap/
.. _`#61`: https://github.com/desihub/desiutil/pull/61
.. _`#63`: https://github.com/desihub/desiutil/pull/63

1.9.3 (2017-03-01)
------------------
Expand Down
20 changes: 10 additions & 10 deletions py/desiutil/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ def get_clip(value):


def init_sky(projection='eck4', ra_center=120, galactic_plane_color='red',
ra_labels=np.arange(-60, 90, 30),
dec_labels=np.arange(0, 360, 60) ,ax=None):
ra_labels=np.arange(0, 360, 60),
dec_labels=np.arange(-60, 90, 30), ax=None):
"""Initialize a basemap projection of the full sky.
The returned Basemap object is augmented with an ``ellipse()`` method to
Expand Down Expand Up @@ -455,16 +455,16 @@ def ellipse(self, x0, y0, a, b, n, ax=None, **kwargs):
m = BasemapWithEllipse(
projection=projection, lon_0=ra_center, resolution=None,
celestial=False, ax=ax)
if dec_labels is not None:
if ra_labels is not None:
if projection in ('hammer', 'moll'):
labels = [0, 0, 0, 0]
else:
labels = [0, 0, 1, 0]
m.drawmeridians(
dec_labels, labels=labels, labelstyle='+/-')
if ra_labels is not None:
ra_labels, labels=labels, labelstyle='+/-')
if dec_labels is not None:
m.drawparallels(
ra_labels, labels=[1, 1, 0, 0], labelstyle='+/-')
dec_labels, labels=[1, 1, 0, 0], labelstyle='+/-')
m.drawmapboundary()

# Draw the optional galactic plane.
Expand Down Expand Up @@ -572,12 +572,12 @@ def plot_healpix_map(data, nest=False, cmap='viridis', colorbar=True,
collection = PolyCollection(
verts, array=data, cmap=cmap, norm=norm, edgecolors='none')

plt.gca().add_collection(collection)
plt.gca().autoscale_view()
basemap.ax.add_collection(collection)
basemap.ax.autoscale_view()

if colorbar:
bar = plt.colorbar(
collection, orientation='horizontal',
collection, ax=basemap.ax, orientation='horizontal',
spacing='proportional', pad=0.01, aspect=50)
if label:
bar.set_label(label)
Expand Down Expand Up @@ -691,7 +691,7 @@ def plot_grid_map(data, ra_edges, dec_edges, cmap='viridis', colorbar=True,

if colorbar:
bar = plt.colorbar(
mesh, orientation='horizontal',
mesh, ax=basemap.ax, orientation='horizontal',
spacing='proportional', pad=0.01, aspect=50)
if label:
bar.set_label(label)
Expand Down

0 comments on commit 0f022fb

Please sign in to comment.