6

I'm reading data in from a FITS file and plotting a velocity field. I'm using set_major_formatter('dd:mm') for the angle on the y-axis, but for every other tick it's only displaying the minutes. I want the full degrees and minutes to show up for each tick label.

fig = plt.figure(dpi=300)
plt.set_cmap('gray')
ax = plt.subplot(111, projection=wcs)
im = ax.imshow(mean_vel, vmin=-115, vmax=-102, origin='lower') # plot data

dec = ax.coords[1]
dec.set_major_formatter('dd:mm')
dec.set_ticks([29.5, 30, 30.5, 31, 31.5, 32, 32.5, 33] *u.deg)
dec.set_ticklabel(size=6)

Current image

For example the 00' on the y-axis should be displayed as 32°00' instead

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • 1
    Looking at [the documentation](http://wcsaxes.readthedocs.io/en/latest/ticks_labels_grid.html) this behaviour is at least expected. – ImportanceOfBeingErnest Apr 23 '17 at 22:20
  • I suggest you use the package `aplpy` for plotting fits images. It is very flexible when it comes to edit the figure aesthetic. Regarding your issue, you can specify the [label formatting](http://aplpy.readthedocs.io/en/stable/arbitrary_coordinate_systems.html#label-formatting) with zero hassle. Cleaner code = better code – VinceP Apr 24 '17 at 10:20
  • 1
    @VinceP: aplpy may be moving toward becoming deprecated; `wcsaxes` (the approach taken by the OP) is preferred. – keflavich Apr 24 '17 at 19:05

1 Answers1

0

As another has said, this behaviour is expected and built in to Astropy via the TickLabels class function simplify_labels (see Astropy source). (It is horrible practice but...) Commenting out the call that the tick label positioner _set_xy_alignments makes to simplify_labels clears up the issues with over-simplifying the labels.

NJM
  • 1