Thank you very much for your thoughtful reply. Indeed, the code
fragment I sent was incomplete and not expected to do nothing else
than illustrate the general idea (what, hopefully, it did).
You suggested collections, and in my previous attempts I have already
used them (worked quite well, but did not solved my problem).
Perhaps my problem is a simpler than I am being able to see and it is
(still) related to using MPL/Basemap embedded in a wx GUI. Well, in my
previously presented sample application for plotting point-coordinate
datasets (in that case, corresponding to cities) on a Basemap, I have
checkboxes which I use to toggle the points on the map on and off. I
do this by storing the plot corresponding to each dataset in a Python
where map is a Basemap instance and longs,lats are float arrays of
geographic coordinates in decimal format.
Then, in a checkbox event, I do the following:
index = event.GetSelection()
plot = self.plot_list[index]
This works quite well and points are properly toggled on/off the Basemap.
But then I want to plot minimum spanning trees connecting the point
datasets. For this I do:
n = len(nodes)
for i in range(n):
t = edges[i,0]-1
u = edges[i,1]-1
x = [nodes[t,0], nodes[u,0]]
y = [nodes[t,1], nodes[u,1]]
where nodes is the array of point coordinates and edges are the
from/to indexes of the coordinates, computed with Prim's algorithm.
The lines between points (representing the minimum spanning tree) are
displayed OK. But then my problem appears: I cannot find a way to turn
the entire tree (which is composed of n-1 line segments) on and off of
the map in the same way I do with the points (as shown above). What I
would like is to store all line segments inside the for loop, and then
show the tree at once, outside the loop; so I could use the same
"plot.set_visible(True|False)" I use for the points.
Searching the list archives, I found that more than an year ago,
another user, Mr. David Clark, had about the same problem
answer to him helped me with toggling of the points, but not with the
Well, hope to have been as clear as possible.
Thanks in advance for any assistance you can provide, and for your patience!
With best regards,
2008/11/27 John Hunter <jdh2358@...287...>:
Could you be a little bit more clear about your use case? In the code
above, nothing is drawn inside the loop. The Line2D is created but not
rendered until a figure draw command is issued. So it would help to
know what it is that you are trying to achieve, rather than simply the
approach to the solution you are taking.
Dr. Mauro J. Cavalcanti
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
Linux Registered User #473524 * Ubuntu User #22717
"Life is complex. It consists of real and imaginary parts."