Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Commit

Permalink
Merge pull request #88 from anizami/frame-settings
Browse files Browse the repository at this point in the history
Added methods to set frame linewidth and color
  • Loading branch information
astrofrog committed Jul 12, 2014
2 parents 4160ed8 + 3a74d24 commit fa6a9e2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion wcsaxes/coordinates_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, axes, wcs=None, transform=None, coord_meta=None,

# Keep track of parent axes and WCS
self._axes = axes

if wcs is None:
if transform is None:
raise ValueError("Either `wcs` or `transform` are required")
Expand Down
26 changes: 25 additions & 1 deletion wcsaxes/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def __init__(self, parent_axes, transform):

self.parent_axes = parent_axes
self._transform = transform
self._linewidth = None
self._color = 'black'

for axis in self.spine_names:
self[axis] = Spine(parent_axes, transform)
Expand Down Expand Up @@ -115,7 +117,7 @@ def patch(self):
def draw(self, renderer):
for axis in self:
x, y = self[axis].pixel[:,0], self[axis].pixel[:,1]
line = Line2D(x, y, color='black', zorder=1000)
line = Line2D(x, y, linewidth=self._linewidth, color=self._color, zorder=1000)
line.draw(renderer)

def sample(self, n_samples):
Expand All @@ -135,6 +137,28 @@ def sample(self, n_samples):

return spines

def set_color(self, color):
"""
Sets the color of the frame.
Parameters
----------
color : string
The color of the frame.
"""
self._color = color

def set_linewidth(self, linewidth):
"""
Sets the linewidth of the frame.
Parameters
----------
linewidth : float
The linewidth of the frame in points.
"""
self._linewidth = linewidth


class RectangularFrame(BaseFrame):

Expand Down
Binary file modified wcsaxes/tests/baseline_images/overlay_features_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions wcsaxes/tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def test_overlay_features_image(self, generate):
# Set labels on axes
ax.coords['glon'].set_axislabel('Galactic Longitude', minpad=1.6)
ax.coords['glat'].set_axislabel('Galactic Latitude', minpad=-0.75)
# Change the frame linewidth and color
ax.coords.frame.set_color('red')
ax.coords.frame.set_linewidth(2)

self.generate_or_test(generate, fig, 'overlay_features_image.png')

Expand Down

0 comments on commit fa6a9e2

Please sign in to comment.