Skip to content
11 changes: 8 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ astropy.convolution
astropy.coordinates
^^^^^^^^^^^^^^^^^^^

- The ``SkyCoord.from_name`` constructor now has the ability to create
coordinate objects by parsing object catalogue names that have embedded
- The ``SkyCoord.from_name`` constructor now has the ability to create
coordinate objects by parsing object catalogue names that have embedded
J-coordinates. [#7830]

- The new function ``make_transform_graph_docs`` can be used to create a
docstring graph from a custom ``TransformGraph`` object. [#7135]

Expand Down Expand Up @@ -216,6 +216,11 @@ astropy.visualization
- Allow ``coord_meta=`` in WCSAxes to optionally include ``format_unit=``.
[#7848]

- WCSAxes now recognizes more rcParams related to the grid, ticks, and labels, and
should work with most built-in Matplotlib styles. [#7961]

- Improved rendering of WCSAxes with outward-facing ticks. [#7961]

astropy.wcs
^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion astropy/tests/image_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

MPL_VERSION = matplotlib.__version__

ROOT = "http://{server}/testing/astropy/2018-03-27T18:38:34.793133/{mpl_version}/"
ROOT = "http://{server}/testing/astropy/2018-10-24T12:38:34.134556/{mpl_version}/"
IMAGE_REFERENCE_DIR = (ROOT.format(server='data.astropy.org', mpl_version=MPL_VERSION[:3] + '.x') + ',' +
ROOT.format(server='www.astropy.org/astropy-data', mpl_version=MPL_VERSION[:3] + '.x'))

Expand Down
10 changes: 10 additions & 0 deletions astropy/visualization/wcsaxes/axislabels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np

from matplotlib import rcParams
from matplotlib.text import Text
import matplotlib.transforms as mtransforms

Expand All @@ -12,6 +13,15 @@
class AxisLabels(Text):

def __init__(self, frame, minpad=1, *args, **kwargs):

# Use rcParams if the following parameters were not specified explicitly
if 'weight' not in kwargs:
kwargs['weight'] = rcParams['axes.labelweight']
if 'size' not in kwargs:
kwargs['size'] = rcParams['axes.labelsize']
if 'color' not in kwargs:
kwargs['color'] = rcParams['axes.labelcolor']

self._frame = frame
super().__init__(*args, **kwargs)
self.set_clip_on(True)
Expand Down
7 changes: 4 additions & 3 deletions astropy/visualization/wcsaxes/coordinate_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, parent_axes=None, parent_map=None, transform=None,
self.ticklabels = TickLabels(self.frame,
transform=None, # display coordinates
figure=parent_axes.get_figure())
self.ticks.display_minor_ticks(False)
self.ticks.display_minor_ticks(rcParams['xtick.minor.visible'])
self.minor_frequency = 5

# Initialize axis labels
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(self, parent_axes=None, parent_map=None, transform=None,
'edgecolor': rcParams['grid.color'],
'linestyle': lines_to_patches_linestyle[rcParams['grid.linestyle']],
'linewidth': rcParams['grid.linewidth'],
'alpha': rcParams.get('grid.alpha', 1.0),
'alpha': rcParams['grid.alpha'],
'transform': self.parent_axes.transData}

def grid(self, draw_grid=True, grid_type=None, **kwargs):
Expand Down Expand Up @@ -521,7 +521,8 @@ def _draw_ticks(self, renderer, bboxes, ticklabels_bbox, ticks_locs):

self.ticks.draw(renderer, ticks_locs)
self.ticklabels.draw(renderer, bboxes=bboxes,
ticklabels_bbox=ticklabels_bbox)
ticklabels_bbox=ticklabels_bbox,
tick_out_size=self.ticks.out_size)

renderer.close_group('ticks')

Expand Down
4 changes: 4 additions & 0 deletions astropy/visualization/wcsaxes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import numpy as np

from matplotlib import rcParams
from matplotlib.artist import Artist
from matplotlib.axes import Axes, subplot_class_factory
from matplotlib.transforms import Affine2D, Bbox, Transform
Expand Down Expand Up @@ -392,6 +393,9 @@ def reset_wcs(self, wcs=None, slices=None, transform=None, coord_meta=None):
self.coords[coord_index].set_ticklabel_position('')
self.coords[coord_index].set_ticks_position('')

if rcParams['axes.grid']:
self.grid()

def draw_wcsaxes(self, renderer):

# Here need to find out range of all coordinates, and update range for
Expand Down
7 changes: 4 additions & 3 deletions astropy/visualization/wcsaxes/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np


from matplotlib import rcParams
from matplotlib.lines import Line2D, Path
from matplotlib.patches import PathPatch

Expand Down Expand Up @@ -97,8 +98,8 @@ def __init__(self, parent_axes, transform, path=None):

self.parent_axes = parent_axes
self._transform = transform
self._linewidth = 1
self._color = 'black'
self._linewidth = rcParams['axes.linewidth']
self._color = rcParams['axes.edgecolor']
self._path = path

for axis in self.spine_names:
Expand Down Expand Up @@ -137,7 +138,7 @@ def _update_patch_path(self):
def patch(self):
self._update_patch_path()
return PathPatch(self._path, transform=self.parent_axes.transData,
facecolor='white', edgecolor='white')
facecolor=rcParams['axes.facecolor'], edgecolor='white')

def draw(self, renderer):
for axis in self:
Expand Down
4 changes: 0 additions & 4 deletions astropy/visualization/wcsaxes/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class TestFrame(BaseImageTests):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='custom_frame.png',
tolerance=0, style={})
def test_custom_frame(self):

Expand Down Expand Up @@ -80,7 +79,6 @@ def test_custom_frame(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='update_clip_path_rectangular.png',
tolerance=0, style={})
def test_update_clip_path_rectangular(self, tmpdir):

Expand All @@ -104,7 +102,6 @@ def test_update_clip_path_rectangular(self, tmpdir):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='update_clip_path_nonrectangular.png',
tolerance=0, style={})
def test_update_clip_path_nonrectangular(self, tmpdir):

Expand All @@ -129,7 +126,6 @@ def test_update_clip_path_nonrectangular(self, tmpdir):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='update_clip_path_change_wcs.png',
tolerance=0, style={})
def test_update_clip_path_change_wcs(self, tmpdir):

Expand Down
46 changes: 26 additions & 20 deletions astropy/visualization/wcsaxes/tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class TestBasic(BaseImageTests):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='image_plot.png',
tolerance=0, style={})
def test_image_plot(self):
# Test for plotting image and also setting values of ticks
Expand All @@ -60,7 +59,7 @@ def test_image_plot(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
tolerance=1.5)
tolerance=1.5, style={})
@pytest.mark.parametrize('axisbelow', [True, False, 'line'])
def test_axisbelow(self, axisbelow):
# Test that tick marks, labels, and gridlines are drawn with the
Expand All @@ -87,7 +86,6 @@ def test_axisbelow(self, axisbelow):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='contour_overlay.png',
tolerance=0, style={})
def test_contour_overlay(self):
# Test for overlaying contours on images
Expand Down Expand Up @@ -119,7 +117,6 @@ def test_contour_overlay(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='contourf_overlay.png',
tolerance=0, style={})
def test_contourf_overlay(self):
# Test for overlaying contours on images
Expand Down Expand Up @@ -151,7 +148,6 @@ def test_contourf_overlay(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='overlay_features_image.png',
tolerance=0, style={})
def test_overlay_features_image(self):

Expand Down Expand Up @@ -190,7 +186,6 @@ def test_overlay_features_image(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='curvlinear_grid_patches_image.png',
tolerance=0, style={})
def test_curvilinear_grid_patches_image(self):

Expand Down Expand Up @@ -224,7 +219,6 @@ def test_curvilinear_grid_patches_image(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='cube_slice_image.png',
tolerance=0, style={})
def test_cube_slice_image(self):

Expand Down Expand Up @@ -252,7 +246,6 @@ def test_cube_slice_image(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='cube_slice_image_lonlat.png',
tolerance=0, style={})
def test_cube_slice_image_lonlat(self):

Expand Down Expand Up @@ -324,7 +317,6 @@ def test_plot_line(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='changed_axis_units.png',
tolerance=0, style={})
def test_changed_axis_units(self):
# Test to see if changing the units of axis works
Expand All @@ -344,7 +336,6 @@ def test_changed_axis_units(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='minor_ticks_image.png',
tolerance=0, style={})
def test_minor_ticks(self):
# Test for drawing minor ticks
Expand All @@ -365,7 +356,6 @@ def test_minor_ticks(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='ticks_labels.png',
tolerance=0, style={})
def test_ticks_labels(self):
fig = plt.figure(figsize=(6, 6))
Expand Down Expand Up @@ -395,31 +385,51 @@ def test_ticks_labels(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='rcparams.png',
tolerance=0, style={})
def test_rcparams(self):
# Test default style (matplotlib.rcParams) for ticks and gridlines

# Test custom rcParams

with rc_context({

'axes.labelcolor': 'purple',
'axes.labelsize': 14,
'axes.labelweight': 'bold',

'axes.linewidth': 3,
'axes.facecolor': '0.5',
'axes.edgecolor': 'green',

'xtick.color': 'red',
'xtick.labelsize': 8,
'xtick.direction': 'in',

'xtick.minor.visible': True,
'xtick.minor.size': 5,

'xtick.major.size': 20,
'xtick.major.width': 2,
'xtick.major.width': 3,
'xtick.major.pad': 10,

'grid.color': 'blue',
'grid.linestyle': ':',
'grid.linewidth': 1,
'grid.alpha': 0.5}):

fig = plt.figure(figsize=(6, 6))
ax = WCSAxes(fig, [0.1, 0.1, 0.7, 0.7], wcs=None)
ax = WCSAxes(fig, [0.15, 0.1, 0.7, 0.7], wcs=None)
fig.add_axes(ax)
ax.set_xlim(-0.5, 2)
ax.set_ylim(-0.5, 2)
ax.grid()
ax.set_xlabel('X label')
ax.set_ylabel('Y label')
ax.coords[0].set_ticks(exclude_overlapping=True)
ax.coords[1].set_ticks(exclude_overlapping=True)
return fig

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='tick_angles.png',
tolerance=0, style={})
def test_tick_angles(self):
# Test that tick marks point in the correct direction, even when the
Expand Down Expand Up @@ -447,7 +457,6 @@ def test_tick_angles(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='tick_angles_non_square_axes.png',
tolerance=0, style={})
def test_tick_angles_non_square_axes(self):
# Test that tick marks point in the correct direction, even when the
Expand Down Expand Up @@ -476,7 +485,6 @@ def test_tick_angles_non_square_axes(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='set_coord_type.png',
tolerance=0, style={})
def test_set_coord_type(self):
# Test for setting coord_type
Expand All @@ -496,7 +504,6 @@ def test_set_coord_type(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='test_ticks_regression_1.png',
tolerance=0, style={})
def test_ticks_regression(self):
# Regression test for a bug that caused ticks aligned exactly with a
Expand All @@ -521,7 +528,6 @@ def test_ticks_regression(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='test_axislabels_regression.png',
savefig_kwargs={'bbox_inches': 'tight'},
tolerance=0, style={})
def test_axislabels_regression(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class TestTransformCoordMeta(BaseImageTests):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='coords_overlay.png',
tolerance=0, style={})
def test_coords_overlay(self):

Expand Down Expand Up @@ -110,7 +109,6 @@ def test_coords_overlay(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='coords_overlay_auto_coord_meta.png',
tolerance=0, style={})
def test_coords_overlay_auto_coord_meta(self):

Expand All @@ -135,7 +133,6 @@ def test_coords_overlay_auto_coord_meta(self):

@pytest.mark.remote_data(source='astropy')
@pytest.mark.mpl_image_compare(baseline_dir=IMAGE_REFERENCE_DIR,
filename='direct_init.png',
tolerance=0, style={})
def test_direct_init(self):

Expand Down
Loading