## Re: [Matplotlib-users] Toggling points and legends

 Re: [Matplotlib-users] Toggling points and legends From: Mauro Cavalcanti - 2008-12-01 22:48:20 ```Dear Ryan, Thank your very much for your kind reply. I had already a couple of solutions to that problem, and your adds nicely to them! I am very grateful to everyone who have been so helpful and can assure you will also be formally acknowledged at the conclusion of this project. With warmest regards, 2008/12/1 Ryan May : > Mauro Cavalcanti wrote: >> >> Dear ALL, >> >> Is there any example of toggling points on and off a MPL Basemap? I >> see that there matplotlib artists have a handy "set_visible()" method, >> but if I have a map with plotted points and use >> "ax.set_visible(False)", the entire map is made invisible! > > Sorry this took so long, I lost you in my queue. > > You need to first save the results of the command you use to plot the points > (every plotting command returns an object or set of objects that represent > what was added to the plot.). You then call set_visible() on this object. > Your problem was that calling ax.set_visible(False) made the entire Axes > object invisible, which, as you saw, hid the plot. Here's a modified version > of the plotcities example: > > > from mpl_toolkits.basemap import Basemap as Basemap > > m = Basemap() > x, y = [70,30,110,-97,75,-10], [35, 40, 45, 60, -10, -40] > x,y = m(x,y) > m.drawcoastlines() > m.fillcontinents() > pts = m.scatter(x,y,25,marker='o',edgecolors='none',zorder=10) > pts.set_visible(False) #Uncomment to make visible > plt.show() > > Hope this helps, > > Ryan > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma > -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: maurobio@... Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." ```

 [Matplotlib-users] Toggling points and legends From: Mauro Cavalcanti - 2008-11-22 11:50:50 ```Dear ALL, Is there any example of toggling points on and off a MPL Basemap? I see that there matplotlib artists have a handy "set_visible()" method, but if I have a map with plotted points and use "ax.set_visible(False)", the entire map is made invisible! Any hints? Thanks in advance! Best regards, -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: maurobio@... Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." ```
 Re: [Matplotlib-users] Toggling points and legends From: Ryan May - 2008-12-01 21:44:33 ```Mauro Cavalcanti wrote: > Dear ALL, > > Is there any example of toggling points on and off a MPL Basemap? I > see that there matplotlib artists have a handy "set_visible()" method, > but if I have a map with plotted points and use > "ax.set_visible(False)", the entire map is made invisible! Sorry this took so long, I lost you in my queue. You need to first save the results of the command you use to plot the points (every plotting command returns an object or set of objects that represent what was added to the plot.). You then call set_visible() on this object. Your problem was that calling ax.set_visible(False) made the entire Axes object invisible, which, as you saw, hid the plot. Here's a modified version of the plotcities example: from mpl_toolkits.basemap import Basemap as Basemap m = Basemap() x, y = [70,30,110,-97,75,-10], [35, 40, 45, 60, -10, -40] x,y = m(x,y) m.drawcoastlines() m.fillcontinents() pts = m.scatter(x,y,25,marker='o',edgecolors='none',zorder=10) pts.set_visible(False) #Uncomment to make visible plt.show() Hope this helps, Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma ```
 Re: [Matplotlib-users] Toggling points and legends From: Mauro Cavalcanti - 2008-12-01 22:48:20 ```Dear Ryan, Thank your very much for your kind reply. I had already a couple of solutions to that problem, and your adds nicely to them! I am very grateful to everyone who have been so helpful and can assure you will also be formally acknowledged at the conclusion of this project. With warmest regards, 2008/12/1 Ryan May : > Mauro Cavalcanti wrote: >> >> Dear ALL, >> >> Is there any example of toggling points on and off a MPL Basemap? I >> see that there matplotlib artists have a handy "set_visible()" method, >> but if I have a map with plotted points and use >> "ax.set_visible(False)", the entire map is made invisible! > > Sorry this took so long, I lost you in my queue. > > You need to first save the results of the command you use to plot the points > (every plotting command returns an object or set of objects that represent > what was added to the plot.). You then call set_visible() on this object. > Your problem was that calling ax.set_visible(False) made the entire Axes > object invisible, which, as you saw, hid the plot. Here's a modified version > of the plotcities example: > > > from mpl_toolkits.basemap import Basemap as Basemap > > m = Basemap() > x, y = [70,30,110,-97,75,-10], [35, 40, 45, 60, -10, -40] > x,y = m(x,y) > m.drawcoastlines() > m.fillcontinents() > pts = m.scatter(x,y,25,marker='o',edgecolors='none',zorder=10) > pts.set_visible(False) #Uncomment to make visible > plt.show() > > Hope this helps, > > Ryan > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma > -- Dr. Mauro J. Cavalcanti Ecoinformatics Studio P.O. Box 46521, CEP 20551-970 Rio de Janeiro, RJ, BRASIL E-mail: maurobio@... Web: http://studio.infobio.net Linux Registered User #473524 * Ubuntu User #22717 "Life is complex. It consists of real and imaginary parts." ```