Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add spines and ticks in rcParams #2702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ def validate_bbox(s):
return None
raise ValueError("bbox should be 'tight' or 'standard'")

validate_xtick_position = ValidateInStrings('xtick.position',
['both', 'bottom', 'top', 'none'])

validate_ytick_position = ValidateInStrings('ytick.position',
['both', 'left', 'right', 'none'])


def validate_sketch(s):
if s == 'None' or s is None:
return None
Expand Down Expand Up @@ -574,6 +581,12 @@ def __call__(self, s):
'axes.facecolor': ['w', validate_color], # background color; white
'axes.edgecolor': ['k', validate_color], # edge color; black
'axes.linewidth': [1.0, validate_float], # edge linewidth

'axes.spines.left': [True, validate_bool], # Set visibility of axes
'axes.spines.right': [True, validate_bool], # 'spines', the lines
'axes.spines.bottom': [True, validate_bool], # around the chart
'axes.spines.top': [True, validate_bool], # denoting data boundary

'axes.titlesize': ['large', validate_fontsize], # fontsize of the
# axes title
'axes.titleweight': ['normal', six.text_type], # font weight of axes title
Expand Down Expand Up @@ -659,6 +672,7 @@ def __call__(self, s):
# fontsize of the xtick labels
'xtick.labelsize': ['medium', validate_fontsize],
'xtick.direction': ['in', six.text_type], # direction of xticks
'xtick.position': ['both', validate_xtick_position],

'ytick.major.size': [4, validate_float], # major ytick size in points
'ytick.minor.size': [2, validate_float], # minor ytick size in points
Expand All @@ -670,6 +684,7 @@ def __call__(self, s):
# fontsize of the ytick labels
'ytick.labelsize': ['medium', validate_fontsize],
'ytick.direction': ['in', six.text_type], # direction of yticks
'ytick.position': ['both', validate_ytick_position],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this doing anything? I can't see any diffs which are making use of it.


'grid.color': ['k', validate_color], # grid color
'grid.linestyle': [':', six.text_type], # dotted
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/spines.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ def linear_spine(cls, axes, spine_type, **kwargs):
else:
raise ValueError('unable to make path for spine "%s"' % spine_type)
result = cls(axes, spine_type, path, **kwargs)
if not rcParams['axes.spines.{0}'.format(spine_type)]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a .get call in case "type" is something else (from a subclass of Axes).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would also make it more clear what the default value was result.set_visible(rcParams.get('axes.spines.{}'.format(spine_type), True))

result.set_visible(False)

return result

@classmethod
Expand Down