| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,10 @@ | |||
| 1 | + API CHANGES in matplotlib-0.65 | ||
| 2 | + | ||
| 3 | + Did away with the text methods for angle since they were ambiguous. | ||
| 4 | + fontangle could mean fontstyle (obligue, etc) or the rotation of the | ||
| 5 | + text. Use style and rotation instead. | ||
| 6 | + | ||
| 7 | + | ||
| 1 | 8 | API CHANGES in matplotlib-0.63 | |
| 2 | 9 | ||
| 3 | 10 | Dates are now represented internally as float days since 0001-01-01, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | #!/usr/bin/env python | |
| 2 | 2 | #Controlling the properties of axis text using handles | |
| 3 | 3 | ||
| 4 | - # See axis_text_themes.py for a more elegant, pythonic way to control | ||
| 4 | + # See examples/text_themes.py for a more elegant, pythonic way to control | ||
| 5 | 5 | # fonts. After all, if we were slaves to matlab , we wouldn't be | |
| 6 | 6 | # using python! | |
| 7 | 7 | ||
@@ -24,17 +24,7 @@ def f(t): | |||
| 24 | 24 | ytext = ylabel('Damped oscillation') | |
| 25 | 25 | xtext = xlabel('time (s)') | |
| 26 | 26 | ||
| 27 | - set(ttext, 'fontsize', 'large') | ||
| 28 | - set(ttext, 'color', 'r') | ||
| 29 | - set(ttext, 'fontangle', 'italic') | ||
| 30 | - | ||
| 31 | - set(xtext, 'fontsize', 'medium') | ||
| 32 | - set(xtext, 'fontname', 'courier') | ||
| 33 | - set(xtext, 'fontweight', 'bold') | ||
| 34 | - set(xtext, 'color', 'g') | ||
| 35 | - | ||
| 36 | - set(ytext, 'fontsize', 'medium') | ||
| 37 | - set(ytext, 'fontname', 'helvetica') | ||
| 38 | - set(ytext, 'fontweight', 'light') | ||
| 39 | - set(ytext, 'color', 'b') | ||
| 27 | + set(ttext, size='large', color='r', style='italic') | ||
| 28 | + set(xtext, size='medium', name='courier', weight='bold', color='g') | ||
| 29 | + set(ytext, size='medium', name='helvetica', weight='light', color='b') | ||
| 40 | 30 | show() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | 4 | font = {'family' : 'serif', | |
| 5 | 5 | 'color' : 'r', | |
| 6 | - 'fontweight' : 'normal', | ||
| 7 | - 'fontsize' : 12, | ||
| 6 | + 'weight' : 'normal', | ||
| 7 | + 'size' : 12, | ||
| 8 | 8 | } | |
| 9 | 9 | ||
| 10 | 10 | def f(t): | |
@@ -16,9 +16,9 @@ def f(t): | |||
| 16 | 16 | t2 = arange(0.0, 5.0, 0.02) | |
| 17 | 17 | ||
| 18 | 18 | plot(t1, f(t1), 'bo', t2, f(t2), 'k') | |
| 19 | - title('Damped exponential decay', font, fontsize='large', color='r') | ||
| 19 | + title('Damped exponential decay', font, size='large', color='r') | ||
| 20 | 20 | text(2, 0.65, 'cos(2 pi t) exp(-t)', font, color='k', family='monospace' ) | |
| 21 | - xlabel('time (s)', font, fontangle='italic') | ||
| 21 | + xlabel('time (s)', font, style='italic') | ||
| 22 | 22 | ylabel('voltage (mV)', font) | |
| 23 | 23 | ||
| 24 | 24 | #savefig('text_themes') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,24 @@ | |||
| 3 | 3 | from cbook import True, False | |
| 4 | 4 | from transforms import identity_transform | |
| 5 | 5 | ||
| 6 | + ## Note, matplotlib artists use the doc strings for set and get | ||
| 7 | + # methods to enable the introspection methods of set and get in the | ||
| 8 | + # matlab interface Every set_ to be controlled by the set function | ||
| 9 | + # method should have a docstring containing the line | ||
| 10 | + # | ||
| 11 | + # ACCEPTS: [ legal | values ] | ||
| 12 | + # | ||
| 13 | + # and aliases for setters and getters should have a docstring that | ||
| 14 | + # starts with 'alias for ', as in 'alias for set_somemethod' | ||
| 15 | + # | ||
| 16 | + # You may wonder why we use so much boiler-plate manually defining the | ||
| 17 | + # set_alias and get_alias functions, rather than using some clever | ||
| 18 | + # python trick. The answer is that I need to be able to manipulate | ||
| 19 | + # the docstring, and there is no clever way to do that in python 2.2, | ||
| 20 | + # as far as I can see - see | ||
| 21 | + # http://groups.google.com/groups?hl=en&lr=&threadm=mailman.5090.1098044946.5135.python-list%40python.org&rnum=1&prev=/groups%3Fq%3D__doc__%2Bauthor%253Ajdhunter%2540ace.bsd.uchicago.edu%26hl%3Den%26btnG%3DGoogle%2BSearch | ||
| 22 | + | ||
| 23 | + | ||
| 6 | 24 | class Artist: | |
| 7 | 25 | """ | |
| 8 | 26 | Abstract base class for someone who renders into a FigureCanvas | |
@@ -59,8 +77,8 @@ def set_clip_box(self, clipbox): | |||
| 59 | 77 | ||
| 60 | 78 | def get_alpha(self): | |
| 61 | 79 | """ | |
| 62 | - Return the alpha value used for blending - not supported on | ||
| 63 | - all backends | ||
| 80 | + Return the alpha value used for blending - not supported on all | ||
| 81 | + backends | ||
| 64 | 82 | """ | |
| 65 | 83 | return self._alpha | |
| 66 | 84 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -769,7 +769,6 @@ def set_aa(self, val): | |||
| 769 | 769 | 'alias for set_antialiased' | |
| 770 | 770 | self.set_antialiased(val) | |
| 771 | 771 | ||
| 772 | - | ||
| 773 | 772 | def set_c(self, val): | |
| 774 | 773 | 'alias for set_color' | |
| 775 | 774 | self.set_color(val) | |
@@ -804,3 +803,40 @@ def set_ms(self, val): | |||
| 804 | 803 | 'alias for set_markersize' | |
| 805 | 804 | self.set_markersize(val) | |
| 806 | 805 | ||
| 806 | + def get_aa(self): | ||
| 807 | + 'alias for get_antialiased' | ||
| 808 | + return self.get_antialiased() | ||
| 809 | + | ||
| 810 | + def get_c(self): | ||
| 811 | + 'alias for get_color' | ||
| 812 | + return self.get_color() | ||
| 813 | + | ||
| 814 | + | ||
| 815 | + def get_ls(self): | ||
| 816 | + 'alias for get_linestyle' | ||
| 817 | + return self.get_linestyle() | ||
| 818 | + | ||
| 819 | + | ||
| 820 | + def get_lw(self): | ||
| 821 | + 'alias for get_linewidth' | ||
| 822 | + return self.get_linewidth() | ||
| 823 | + | ||
| 824 | + | ||
| 825 | + def get_mec(self): | ||
| 826 | + 'alias for get_markeredgecolor' | ||
| 827 | + return self.get_markeredgecolor() | ||
| 828 | + | ||
| 829 | + | ||
| 830 | + def get_mew(self): | ||
| 831 | + 'alias for get_markeredgewidth' | ||
| 832 | + return self.get_markeredgewidth() | ||
| 833 | + | ||
| 834 | + | ||
| 835 | + def get_mfc(self): | ||
| 836 | + 'alias for get_markerfacecolor' | ||
| 837 | + return self.get_markerfacecolor() | ||
| 838 | + | ||
| 839 | + | ||
| 840 | + def get_ms(self): | ||
| 841 | + 'alias for get_markersize' | ||
| 842 | + return self.get_markersize() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1022,11 +1022,10 @@ def get_aliases(self): | |||
| 1022 | 1022 | aliases = {} | |
| 1023 | 1023 | for name in names: | |
| 1024 | 1024 | func = getattr(self.o, name) | |
| 1025 | + if not self.is_alias(func): continue | ||
| 1025 | 1026 | docstring = func.__doc__ | |
| 1026 | - if docstring is None: continue | ||
| 1027 | - if docstring.startswith('alias for '): | ||
| 1028 | - fullname = docstring[10:] | ||
| 1029 | - aliases[fullname[4:]] = name[4:] | ||
| 1027 | + fullname = docstring[10:] | ||
| 1028 | + aliases[fullname[4:]] = name[4:] | ||
| 1030 | 1029 | return aliases | |
| 1031 | 1030 | ||
| 1032 | 1031 | def get_valid_values(self, attr): | |
@@ -1039,13 +1038,14 @@ def get_valid_values(self, attr): | |||
| 1039 | 1038 | ||
| 1040 | 1039 | name = 'set_%s'%attr | |
| 1041 | 1040 | if not hasattr(self.o, name): | |
| 1042 | - raise AttributeError('%s has no function %s'%(h,name)) | ||
| 1041 | + raise AttributeError('%s has no function %s'%(self.o,name)) | ||
| 1043 | 1042 | func = getattr(self.o, name) | |
| 1044 | 1043 | ||
| 1045 | 1044 | docstring = func.__doc__ | |
| 1046 | 1045 | if docstring is None: return 'unknown' | |
| 1047 | 1046 | ||
| 1048 | - if docstring.startswith('alias'): return docstring | ||
| 1047 | + if docstring.startswith('alias for '): | ||
| 1048 | + return None | ||
| 1049 | 1049 | for line in docstring.split('\n'): | |
| 1050 | 1050 | line = line.lstrip() | |
| 1051 | 1051 | if not line.startswith('ACCEPTS:'): continue | |
@@ -1057,10 +1057,21 @@ def get_setters(self): | |||
| 1057 | 1057 | Get the attribute strings with setters for object h | |
| 1058 | 1058 | """ | |
| 1059 | 1059 | ||
| 1060 | - return [name[4:] for name in dir(self.o) | ||
| 1061 | - if name.startswith('set_') and | ||
| 1062 | - callable(getattr(self.o,name))] | ||
| 1063 | - | ||
| 1060 | + setters = [] | ||
| 1061 | + for name in dir(self.o): | ||
| 1062 | + if not name.startswith('set_'): continue | ||
| 1063 | + o = getattr(self.o,name) | ||
| 1064 | + if not callable(o): continue | ||
| 1065 | + func = o | ||
| 1066 | + if self.is_alias(func): continue | ||
| 1067 | + setters.append(name[4:]) | ||
| 1068 | + return setters | ||
| 1069 | + | ||
| 1070 | + def is_alias(self, o): | ||
| 1071 | + ds = o.__doc__ | ||
| 1072 | + if ds is None: return False | ||
| 1073 | + return ds.startswith('alias for ') | ||
| 1074 | + | ||
| 1064 | 1075 | def aliased_name(self, s): | |
| 1065 | 1076 | """ | |
| 1066 | 1077 | return 'fullname or alias' if s has an alias. | |
@@ -1083,8 +1094,9 @@ def pprint_setters(self, property=None): | |||
| 1083 | 1094 | return ' %s: %s' %(property, accepts) | |
| 1084 | 1095 | ||
| 1085 | 1096 | attrs = self.get_setters() | |
| 1086 | - lines = [] | ||
| 1087 | 1097 | attrs.sort() | |
| 1098 | + lines = [] | ||
| 1099 | + | ||
| 1088 | 1100 | for property in attrs: | |
| 1089 | 1101 | accepts = self.get_valid_values(property) | |
| 1090 | 1102 | name = self.aliased_name(property) | |
@@ -1102,10 +1114,9 @@ def pprint_getters(self): | |||
| 1102 | 1114 | lines = [] | |
| 1103 | 1115 | for name in getters: | |
| 1104 | 1116 | func = getattr(self.o, name) | |
| 1105 | - docstring = func.__doc__ | ||
| 1106 | - if docstring is not None and docstring.startswith('alias'): continue | ||
| 1117 | + if self.is_alias(func): continue | ||
| 1107 | 1118 | try: val = func() | |
| 1108 | - except: pass | ||
| 1119 | + except: continue | ||
| 1109 | 1120 | if iterable(val) and len(val)>6: | |
| 1110 | 1121 | s = str(val[:6]) + '...' | |
| 1111 | 1122 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -135,6 +135,42 @@ def get_window_extent(self, renderer=None): | |||
| 135 | 135 | verts = self.get_verts() | |
| 136 | 136 | tverts = self._transform.seq_xy_tups(verts) | |
| 137 | 137 | return bound_vertices(tverts) | |
| 138 | + | ||
| 139 | + | ||
| 140 | + | ||
| 141 | + def set_lw(self, val): | ||
| 142 | + 'alias for set_linewidth' | ||
| 143 | + self.set_linewidth(val) | ||
| 144 | + | ||
| 145 | + | ||
| 146 | + def set_ec(self, val): | ||
| 147 | + 'alias for set_edgecolor' | ||
| 148 | + self.set_edgecolor(val) | ||
| 149 | + | ||
| 150 | + | ||
| 151 | + def set_fc(self, val): | ||
| 152 | + 'alias for set_facecolor' | ||
| 153 | + self.set_facecolor(val) | ||
| 154 | + | ||
| 155 | + | ||
| 156 | + def get_aa(self): | ||
| 157 | + 'alias for get_antialiased' | ||
| 158 | + return self.get_antialiased() | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + def get_lw(self): | ||
| 162 | + 'alias for get_linewidth' | ||
| 163 | + return self.get_linewidth() | ||
| 164 | + | ||
| 165 | + | ||
| 166 | + def get_ec(self): | ||
| 167 | + 'alias for get_edgecolor' | ||
| 168 | + return self.get_edgecolor() | ||
| 169 | + | ||
| 170 | + | ||
| 171 | + def get_fc(self): | ||
| 172 | + 'alias for get_facecolor' | ||
| 173 | + return self.get_facecolor() | ||
| 138 | 174 | ||
| 139 | 175 | class Rectangle(Patch): | |
| 140 | 176 | """ | |
@@ -323,22 +359,3 @@ def draw_bbox(bbox, renderer, color='k', trans=None): | |||
| 323 | 359 | r.set_clip_on( False ) | |
| 324 | 360 | r.draw(renderer) | |
| 325 | 361 | ||
| 326 | - | ||
| 327 | - def set_aa(self, val): | ||
| 328 | - 'alias for set_antialiased' | ||
| 329 | - self.set_antialiased(val) | ||
| 330 | - | ||
| 331 | - | ||
| 332 | - def set_lw(self, val): | ||
| 333 | - 'alias for set_linewidth' | ||
| 334 | - self.set_linewidth(val) | ||
| 335 | - | ||
| 336 | - | ||
| 337 | - def set_ec(self, val): | ||
| 338 | - 'alias for set_edgecolor' | ||
| 339 | - self.set_edgecolor(val) | ||
| 340 | - | ||
| 341 | - | ||
| 342 | - def set_fc(self, val): | ||
| 343 | - 'alias for set_facecolor' | ||
| 344 | - self.set_facecolor(val) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments