Skip to content

Fixed Issue 4346 #6079

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

Merged
merged 3 commits into from
Mar 4, 2016
Merged
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
2 changes: 1 addition & 1 deletion lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def _apply_params(self, **kw):
# -> points. grab the integer from the `Text` object
# instead of saving the string representation
v = getattr(self.label1, 'get_' + k)()
setattr(self, '_' + k, v)
setattr(self, '_label' + k, v)


class XTick(Tick):
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4335,6 +4335,17 @@ def test_pandas_indexing_hist():
fig, axes = plt.subplots()
axes.hist(ser_2)

@cleanup
def test_axis_set_tick_params_labelsize_labelcolor():
# Tests fix for issue 4346
axis_1 = plt.subplot()
axis_1.yaxis.set_tick_params(labelsize=30, labelcolor='red', direction='out')

# Expected values after setting the ticks
assert axis_1.yaxis.majorTicks[0]._size == 4.0
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reliably way to test this using public API?

Copy link
Member

Choose a reason for hiding this comment

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

The reason for asking that is that, long term, we reserve the right to change the private API with no warning or deprecation cycle. Tests that only use public API give confidence that we have done that right but that is eroded if we have to touch the tests as part of the refactor as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, I didn't consider the public API. I will look into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't seem to find a way to get either of labelsize, labelcolor, size, or color out of the public API. There is a get_markersize in the docs that would return _size, however I don't see it in the code. Should I implement this?

Copy link
Member

Choose a reason for hiding this comment

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

If there is not a good public API, then this is fine. Creating new API for the purpose of testing it is not a good idea!

assert axis_1.yaxis.majorTicks[0]._color == 'k'
assert axis_1.yaxis.majorTicks[0]._labelsize == 30.0
assert axis_1.yaxis.majorTicks[0]._labelcolor == 'red'

if __name__ == '__main__':
import nose
Expand Down