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

Skip to content

Commit cb50207

Browse files
committed
added kwarg support for xticks and yticks
svn path=/trunk/matplotlib/; revision=605
1 parent a0d8a32 commit cb50207

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
New entries should be added at the top
22

33
==============================================================
4+
2004-10-19 Added kwarg support to xticks and yticks to set ticklabel
5+
text properties -- thanks to T. Edward Whalen for the suggestion
6+
47
2004-10-19 Added support for PIL images in imshow(), image.py - ADS
58

69
2004-10-19 Re-worked exception handling in _image.py and _transforms.py

examples/arctest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from matplotlib.matlab import *
33

44
def f(t):
5+
'a damped exponential'
56
s1 = cos(2*pi*t)
67
e1 = exp(-t)
78
return multiply(s1,e1)

lib/matplotlib/matlab.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,21 +1143,26 @@ def xticks(*args, **kwargs):
11431143
11441144
# set the locations and labels of the xticks
11451145
xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )
1146-
1146+
1147+
The keyword args, if any, are text properties; see text for more
1148+
information on text properties.
11471149
"""
11481150
ax = gca()
11491151

11501152
if len(args)==0:
11511153
locs = ax.get_xticks()
11521154
labels = ax.get_xticklabels()
1153-
11541155
elif len(args)==1:
11551156
locs = ax.set_xticks(args[0])
11561157
labels = ax.get_xticklabels()
11571158
elif len(args)==2:
11581159
locs = ax.set_xticks(args[0])
1159-
labels = ax.set_xticklabels(args[1])
1160+
labels = ax.set_xticklabels(args[1], **kwargs)
11601161
else: raise RuntimeError('Illegal number of arguments to xticks')
1162+
if len(kwargs):
1163+
for l in labels:
1164+
l.update_properties(kwargs)
1165+
11611166
draw_if_interactive()
11621167
return locs, labels
11631168

@@ -1174,7 +1179,9 @@ def yticks(*args, **kwargs):
11741179
11751180
# set the locations and labels of the yticks
11761181
yticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )
1177-
1182+
1183+
The keyword args, if any, are text properties; see text for more
1184+
information on text properties.
11781185
"""
11791186
ax = gca()
11801187

@@ -1186,9 +1193,14 @@ def yticks(*args, **kwargs):
11861193
labels = ax.get_yticklabels()
11871194
elif len(args)==2:
11881195
locs = ax.set_yticks(args[0])
1189-
labels = ax.set_yticklabels(args[1])
1196+
labels = ax.set_yticklabels(args[1], **kwargs)
11901197
else: raise RuntimeError('Illegal number of arguments to yticks')
1198+
if len(kwargs):
1199+
for l in labels:
1200+
l.update_properties(kwargs)
1201+
11911202
draw_if_interactive()
1203+
11921204
return locs, labels
11931205

11941206

0 commit comments

Comments
 (0)