|
1 | | - |
2 | 1 | from __future__ import division, generators |
3 | 2 |
|
4 | 3 | import math, sys |
@@ -2892,22 +2891,55 @@ def _send_ylim_event(self): |
2892 | 2891 | func(self) |
2893 | 2892 |
|
2894 | 2893 |
|
2895 | | - def set_xlim(self, v, emit=True): |
| 2894 | + def set_xlim(self, *args, **kwargs): |
2896 | 2895 | """ |
2897 | | - SET_XLIM(v, emit=True) |
| 2896 | + set_xlim(self, *args, **kwargs): |
2898 | 2897 |
|
2899 | 2898 | Set the limits for the xaxis; v = [xmin, xmax] |
| 2899 | + |
| 2900 | + set_xlim((valmin, valmax)) |
| 2901 | + set_xlim(valmin, valmax) |
| 2902 | + set_xlim(xmin=1) # xmax unchanged |
| 2903 | + set_xlim(xmax=1) # xmin unchanged |
| 2904 | +
|
| 2905 | + Valid kwargs: |
2900 | 2906 |
|
2901 | | - If emit is false, do not trigger an event |
| 2907 | + xmin : the min of the xlim |
| 2908 | + xmax : the max of the xlim |
| 2909 | + emit : notify observers of lim change |
| 2910 | + |
| 2911 | +
|
| 2912 | + Returns the current xlimits as a length 2 tuple |
2902 | 2913 |
|
2903 | 2914 | ACCEPTS: len(2) sequence of floats |
2904 | 2915 | """ |
2905 | | - vmin, vmax = v |
| 2916 | + |
| 2917 | + vmin, vmax = self.get_xlim() |
| 2918 | + |
| 2919 | + xmin = popd(kwargs, 'xmin', None) |
| 2920 | + xmax = popd(kwargs, 'xmax', None) |
| 2921 | + emit = popd(kwargs, 'emit', False) |
| 2922 | + if len(args)!=0 and (xmin is not None or xmax is not None): |
| 2923 | + raise TypeError('You cannot pass args and xmin/xmax kwargs') |
| 2924 | + |
| 2925 | + if len(args)==0: |
| 2926 | + if xmin is not None: vmin = xmin |
| 2927 | + if xmax is not None: vmax = xmax |
| 2928 | + elif len(args)==1: |
| 2929 | + vmin, vmax = args[0] |
| 2930 | + elif len(args)==2: |
| 2931 | + vmin, vmax = args |
| 2932 | + else: |
| 2933 | + raise ValueError('args must be length 0, 1 or 2') |
| 2934 | + |
| 2935 | + |
| 2936 | + |
2906 | 2937 | if self.transData.get_funcx().get_type()==LOG10 and min(vmin, vmax)<=0: |
2907 | 2938 | raise ValueError('Cannot set nonpositive limits with log transform') |
2908 | | - self.viewLim.intervalx().set_bounds(*v) |
| 2939 | + |
| 2940 | + self.viewLim.intervalx().set_bounds(vmin, vmax) |
2909 | 2941 | if emit: self._send_xlim_event() |
2910 | | - |
| 2942 | + return vmin, vmax |
2911 | 2943 |
|
2912 | 2944 | def set_xscale(self, value, basex = 10, subsx=None): |
2913 | 2945 | """ |
@@ -2980,20 +3012,56 @@ def set_ylabel(self, ylabel, fontdict=None, **kwargs): |
2980 | 3012 | label.update(kwargs) |
2981 | 3013 | return label |
2982 | 3014 |
|
2983 | | - def set_ylim(self, v, emit=True): |
| 3015 | + |
| 3016 | + def set_ylim(self, *args, **kwargs): |
2984 | 3017 | """ |
2985 | | - SET_YLIM(v, emit=True) |
| 3018 | + set_ylim(self, *args, **kwargs): |
| 3019 | +
|
| 3020 | + Set the limits for the yaxis; v = [ymin, ymax] |
| 3021 | + |
| 3022 | + set_ylim((valmin, valmax)) |
| 3023 | + set_ylim(valmin, valmax) |
| 3024 | + set_ylim(ymin=1) # ymax unchanged |
| 3025 | + set_ylim(ymax=1) # ymin unchanged |
2986 | 3026 |
|
2987 | | - Set the limits for the xaxis; v = [ymin, ymax]. If emit is false, do |
2988 | | - not trigger an event. |
| 3027 | + Valid kwargs: |
| 3028 | +
|
| 3029 | + ymin : the min of the ylim |
| 3030 | + ymax : the max of the ylim |
| 3031 | + emit : notify observers of lim change |
| 3032 | + |
| 3033 | +
|
| 3034 | + Returns the current ylimits as a length 2 tuple |
2989 | 3035 |
|
2990 | 3036 | ACCEPTS: len(2) sequence of floats |
2991 | 3037 | """ |
2992 | | - vmin, vmax = v |
| 3038 | + |
| 3039 | + vmin, vmax = self.get_ylim() |
| 3040 | + |
| 3041 | + ymin = popd(kwargs, 'ymin', None) |
| 3042 | + ymax = popd(kwargs, 'ymax', None) |
| 3043 | + emit = popd(kwargs, 'emit', False) |
| 3044 | + if len(args)!=0 and (ymin is not None or ymax is not None): |
| 3045 | + raise TypeError('You cannot pass args and ymin/ymax kwargs') |
| 3046 | + |
| 3047 | + if len(args)==0: |
| 3048 | + if ymin is not None: vmin = ymin |
| 3049 | + if ymax is not None: vmax = ymax |
| 3050 | + elif len(args)==1: |
| 3051 | + vmin, vmax = args[0] |
| 3052 | + elif len(args)==2: |
| 3053 | + vmin, vmax = args |
| 3054 | + else: |
| 3055 | + raise ValueError('args must be length 0, 1 or 2') |
| 3056 | + |
| 3057 | + |
| 3058 | + |
2993 | 3059 | if self.transData.get_funcy().get_type()==LOG10 and min(vmin, vmax)<=0: |
2994 | 3060 | raise ValueError('Cannot set nonpositive limits with log transform') |
2995 | | - self.viewLim.intervaly().set_bounds(*v) |
| 3061 | + |
| 3062 | + self.viewLim.intervaly().set_bounds(vmin, vmax) |
2996 | 3063 | if emit: self._send_ylim_event() |
| 3064 | + return vmin, vmax |
2997 | 3065 |
|
2998 | 3066 | def set_yscale(self, value, basey=10, subsy=None): |
2999 | 3067 | """ |
|
0 commit comments