@@ -698,10 +698,8 @@ def add_line(self, l):
698698 l .get_transform (), zip (xdata , ydata ))
699699 xdata , ydata = zip (* xys )
700700
701- corners = ( (amin (xdata ), amin (ydata )), (amax (xdata ), amax (ydata )) )
702-
703- self .update_datalim (corners )
704-
701+ self .update_datalim ( zip (xdata , ydata ) )
702+
705703 self .lines .append (l )
706704
707705 def _get_verts_in_data_coords (self , trans , xys ):
@@ -3054,19 +3052,17 @@ def set_xscale(self, value, basex = 10, subsx=None):
30543052 for patch in self .patches :
30553053 xs .extend ([x for x ,y in patch .get_verts ()])
30563054 for collection in self .collections :
3057- xs .extend ([x for x ,y in collection .get_verts ()])
3055+ xs .extend ([x for x ,y in collection .get_verts ()])
30583056 posx = [x for x in xs if x > 0 ]
3059- minx = min (posx )
3060- maxx = max (posx )
3061- # warning, probably breaks inverted axis
3062- self .set_xlim ((0.1 * minx , maxx ))
3063-
3064-
3065-
3057+ if len (posx ):
3058+ minx = min (posx )
3059+ maxx = max (posx )
3060+ # warning, probably breaks inverted axis
3061+ self .set_xlim ((0.1 * minx , maxx ))
3062+
30663063 self .xaxis .set_major_locator (LogLocator (basex ))
30673064 self .xaxis .set_major_formatter (LogFormatterMathtext (basex ))
3068- self .xaxis .set_minor_locator (LogLocator (basex ,subsx ))
3069-
3065+ self .xaxis .set_minor_locator (LogLocator (basex ,subsx ))
30703066 self .transData .get_funcx ().set_type (LOG10 )
30713067 elif value == 'linear' :
30723068 self .xaxis .set_major_locator (AutoLocator ())
@@ -3154,10 +3150,12 @@ def set_yscale(self, value, basey=10, subsy=None):
31543150 for collection in self .collections :
31553151 ys .extend ([y for x ,y in collection .get_verts ()])
31563152 posy = [y for y in ys if y > 0 ]
3157- miny = min (posy )
3158- maxy = max (posy )
3159- # warning, probably breaks inverted axis
3160- self .set_ylim ((0.1 * miny , maxy ))
3153+ if len (posy ):
3154+ miny = min (posy )
3155+ maxy = max (posy )
3156+ # warning, probably breaks inverted axis
3157+ self .set_ylim ((0.1 * miny , maxy ))
3158+
31613159
31623160 self .yaxis .set_major_locator (LogLocator (basey ))
31633161 self .yaxis .set_major_formatter (LogFormatterMathtext (basey ))
@@ -3422,7 +3420,12 @@ def text(self, x, y, s, fontdict=None, **kwargs):
34223420 return t
34233421
34243422
3425-
3423+ def toggle_log_lineary (self ):
3424+ 'toggle between log and linear on the y axis'
3425+ funcy = self .transData .get_funcy ().get_type ()
3426+ if funcy == LOG10 : self .set_yscale ('linear' )
3427+ elif funcy == IDENTITY : self .set_yscale ('log' )
3428+
34263429 def vlines (self , x , ymin , ymax , color = 'k' ):
34273430 """\
34283431 VLINES(x, ymin, ymax, color='k')
@@ -3957,7 +3960,11 @@ def get_xscale(self):
39573960 def get_yscale (self ):
39583961 'return the yaxis scale string'
39593962 return 'polar'
3960-
3963+
3964+ def toggle_log_lineary (self ):
3965+ 'toggle between log and linear axes ignored for polar'
3966+ pass
3967+
39613968class PolarSubplot (SubplotBase , PolarAxes ):
39623969 """
39633970 Create a polar subplot with
@@ -3976,3 +3983,30 @@ def __init__(self, fig, *args, **kwargs):
39763983 SubplotBase .__init__ (self , * args )
39773984 PolarAxes .__init__ (self , fig , [self .figLeft , self .figBottom , self .figW , self .figH ], ** kwargs )
39783985
3986+
3987+ """
3988+ # this is some discarded code I was using to find the minimum positive
3989+ # data point for some log scaling fixes. I realized there was a
3990+ # cleaner way to do it, but am keeping this around as an example for
3991+ # how to get the data out of the axes. Might want to make something
3992+ # like this a method one day, or better yet make get_verts and Artist
3993+ # method
3994+
3995+ minx, maxx = self.get_xlim()
3996+ if minx<=0 or maxx<=0:
3997+ # find the min pos value in the data
3998+ xs = []
3999+ for line in self.lines:
4000+ xs.extend(line.get_xdata())
4001+ for patch in self.patches:
4002+ xs.extend([x for x,y in patch.get_verts()])
4003+ for collection in self.collections:
4004+ xs.extend([x for x,y in collection.get_verts()])
4005+ posx = [x for x in xs if x>0]
4006+ if len(posx):
4007+
4008+ minx = min(posx)
4009+ maxx = max(posx)
4010+ # warning, probably breaks inverted axis
4011+ self.set_xlim((0.1*minx, maxx))
4012+ """
0 commit comments