8000 mep12 changes to axes_props.py by ericmjl · Pull Request #4831 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

mep12 changes to axes_props.py #4831

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 2 commits into from
Jul 31, 2015
Merged
Changes from 1 commit
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
Next Next commit
mep12 changes to axes_props.py
  • Loading branch information
ericmjl committed Jul 30, 2015
commit f8d76160cca7f3a05e13ea2072f37c0f43affbd2
41 changes: 5 additions & 36 deletions examples/pylab_examples/axes_props.py
8000
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
"""
You can control the axis tick and grid properties
"""
Expand All @@ -7,45 +6,17 @@
import numpy as np

t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t, s)
plt.grid(True)

# MATLAB style
xticklines = plt.getp(plt.gca(), 'xticklines')
yticklines = plt.getp(plt.gca(), 'yticklines')
xgridlines = plt.getp(plt.gca(), 'xgridlines')
ygridlines = plt.getp(plt.gca(), 'ygridlines')
xticklabels = plt.getp(plt.gca(), 'xticklabels')
yticklabels = plt.getp(plt.gca(), 'yticklabels')

plt.setp(xticklines, 'linewidth', 3)
plt.setp(yticklines, 'linewidth', 3)
plt.setp(xgridlines, 'linestyle', '-')
plt.setp(ygridlines, 'linestyle', '-')
plt.setp(yticklabels, 'color', 'r', fontsize='medium')
plt.setp(xticklabels, 'color', 'r', fontsize='medium')


plt.show()


"""
# the same script, python style
from pylab import *

t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
s = np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.grid(True)

ticklines = ax.get_xticklines()
ticklines.extend( ax.get_yticklines() )
ticklines.extend(ax.get_yticklines())
gridlines = ax.get_xgridlines()
gridlines.extend( ax.get_ygridlines() )
gridlines.extend(ax.get_ygridlines())
ticklabels = ax.get_xticklabels()
ticklabels.extend( ax.get_yticklabels() )
ticklabels.extend(ax.get_yticklabels())
Copy link
Member

Choose a reason for hiding this comment

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

Could we make these calls cleaner by just concatenating the x and y lists together? Something like ticklines = ax.get_xticklines() + ax.get_yticklines()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I'll give that a shot.


for line in ticklines:
line.set_linewidth(3)
Expand All @@ -57,6 +28,4 @@
label.set_color('r')
label.set_fontsize('medium')

show()

"""
plt.show()
0