How to group object of the class by attribute and plot data using matplotlib
<p>I have a class:</p>

<pre><code>class Spatial(object):
    def __init__(self, id_jenis, jenis, lat, long):
        self.id_jenis=id_jenis
        self.jenis=jenis
        self.lat= lat
        self.long=long

data = []
data.append(Spatial(1,'battery', 1 , 3.4))
data.append(Spatial(2,'rusa', 5 , 3.4))
data.append(Spatial(3,'rusa', 5 , 6.4))
</code></pre>

<p>How to group object of that class by <code>jenis</code> and plot my object <code>Lat</code> is <code>y</code> and <code>Long</code> is <code>X</code> . In my code, how to replace <code>#Lat#</code>,<code>#Long#</code></p>

<pre><code>import matplotlib.pyplot as plt
import numpy as np

colors = plt.cm.Spectral(np.linspace(0, 1, len(dataPerJenis)))

for k, col in zip(dataPerJenis.keys(),colors):
     plt.plot('#Lat#','#Long#' , 'o', markerfacecolor=col, markeredgecolor='k', markersize=3)
</code></pre>