[Matplotlib-users] Help with updating the limits of an axis to reflect the range of new data

2015-03-25 Thread rogerjames99
Hi,

I am trying to draw a polar plot of a sonar scan. The idea being to present
it like a radar display. I have used axisartist to do the ploar plot. This
is working fine but I would like to reset the limits of the radius axis with
each new scan. I have tried a number of ways of doing this without success.
My current code to set up the plot looks like this.



and to update the plot. Like this


I have tried doing the above on the host axes and the auxiliary one and with
different parameters to the relim etc. Nothing seems to work. Before I tried
various other calls to manipulate the extremes but with the same lack of
results. Can anyone set me straight on this? I feel I must be missing
something obvious. However I find the documentation and the class
inheritance hierarchy almost impossible to follow.

Here are a couple of links to snapshots of the output.

Before

  

After

  

Thanks,

Roger



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Help-with-updating-the-limits-of-an-axis-to-reflect-the-range-of-new-data-tp45261.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Help with updating the limits of an axis to reflect the range of new data

2015-03-26 Thread rogerjames99
Hi Thomas,I posted via nabble. It looks like something stripped the code.Here
is the bit where the axes are set updef setup_axes(self, fig, rect):   
"""With custom locator and formatter.Note that the extreme
values are swapped."""transform = PolarAxes.PolarTransform()
   
angle_ticks = [(0, r"$Right$"),   (.5*pi, r"$Forward$"),
  
(pi, r"$Left$")]grid_locator1 = FixedLocator([v for v, s in
angle_ticks])tick_formatter1 = DictFormatter(dict(angle_ticks))   
grid_locator2 = MaxNLocator(4)self.grid_helper =
floating_axes.GridHelperCurveLinear(transform,  
 
extremes=(0, pi, self.sonar_limit, 0),  
 
grid_locator1=grid_locator1,   
grid_locator2=grid_locator2,   
tick_formatter1=tick_formatter1,   
tick_formatter2=None,)   
self.axes = floating_axes.FloatingSubplot(fig, rect,
grid_helper=self.grid_helper)   
self.axes.axis["bottom"].major_ticklabels.set_rotation(180)   
self.axes.axis["left"].set_axis_direction("bottom")   
self.axes.grid(b=True, which='major', color='b', linestyle='-')   
fig.add_subplot(self.axes)# create a parasite axes whose transData
in RA, czself.auxiliary_axes = self.axes.get_aux_axes(transform)   
self.auxiliary_axes.patch = self.axes.patch # for auxiliary_axis to have a
clip path as in axself.axes.patch.zorder=0.9 # but this has a side
effect that the patch is# drawn twice, and
possibly over some other# artists. So, we
decrease the zorder a bit to# prevent this.   
self.lines, = self.auxiliary_axes.plot(self.theta, self.radius)and here is
the bit where the plot is updateddef idleCallback(self):global
rootplotit = Falselogging.debug('Acquire the data lock')   
self.dataLock.acquire()if self.newSonarDataAvailable:   
plotit = Truetheta = self.theta[:]radius =
self.radius[:]selfNewSonarDataAvailable = False   
self.dataLock.release()#theta.insert(0, 0.)#   
theta.append(0.)#radius.insert(0, 0.)#radius.append(0.)   
if plotit:logging.debug('Plotting')   
self.lines.set_data(theta, radius)self.axes.relim()   
self.axes.autoscale_view()self.canvas.draw()if have also put the
full code file  here
  As you can see I
have been trying a few other things. Looks like if am missing the boat
pretty comprehensively!



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Help-with-updating-the-limits-of-an-axis-to-reflect-the-range-of-new-data-tp45261p45269.html
Sent from the matplotlib - users mailing list archive at Nabble.com.--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Help with updating the limits of an axis to reflect the range of new data

2015-03-26 Thread rogerjames99
Ok the last one got garbled.

My apologies to the list but here is another go.

Hi Thomas,

I posted via nabble. It looks like something stripped the code.

Here is the bit where the axes are set up

def setup_axes(self, fig, rect):
"""
With custom locator and formatter.
Note that the extreme values are swapped.
"""

transform = PolarAxes.PolarTransform()

angle_ticks = [(0, r"$Right$"),
   (.5*pi, r"$Forward$"),
   (pi, r"$Left$")]
grid_locator1 = FixedLocator([v for v, s in angle_ticks])
tick_formatter1 = DictFormatter(dict(angle_ticks))

grid_locator2 = MaxNLocator(4)

self.grid_helper = floating_axes.GridHelperCurveLinear(transform,
extremes=(0, pi,
self.sonar_limit, 0),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
tick_formatter2=None,
)
self.axes = floating_axes.FloatingSubplot(fig, rect,
grid_helper=self.grid_helper)
self.axes.axis["bottom"].major_ticklabels.set_rotation(180)
self.axes.axis["left"].set_axis_direction("bottom")
self.axes.grid(b=True, which='major', color='b', linestyle='-')
fig.add_subplot(self.axes)

# create a parasite axes whose transData in RA, cz
self.auxiliary_axes = self.axes.get_aux_axes(transform)

self.auxiliary_axes.patch = self.axes.patch # for auxiliary_axis to
have a clip path as in ax
self.axes.patch.zorder=0.9 # but this has a side effect that the
patch is
# drawn twice, and possibly over some other
# artists. So, we decrease the zorder a bit to
# prevent this.

self.lines, = self.auxiliary_axes.plot(self.theta, self.radius)


and here is the bit where the plot is updated


def idleCallback(self):
global root
plotit = False
logging.debug('Acquire the data lock')
self.dataLock.acquire()
if self.newSonarDataAvailable:
plotit = True
theta = self.theta[:]
radius = self.radius[:]
selfNewSonarDataAvailable = False
self.dataLock.release()
#theta.insert(0, 0.)
#theta.append(0.)
#radius.insert(0, 0.)
#radius.append(0.)
if plotit:
logging.debug('Plotting')
self.lines.set_data(theta, radius)
self.axes.relim()
self.axes.autoscale_view()
self.canvas.draw()

if have also put the full code file  here
  

As you can see I have been trying a few other things. Looks like if am
missing the boat pretty comprehensively!





--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Help-with-updating-the-limits-of-an-axis-to-reflect-the-range-of-new-data-tp45261p45271.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users