hi all,

i'm tring  to wrote some code to do a stem plot from a dictionary of array.

the code is :


    def multi_stem_plot(self, key, name, title="", time_min="", time_max=""):
        """ doc """
        rows = len(key)
        cols = 1
        gr = str(rows)+str(cols)
        for i in enumerate(key):
            ylabel = key[i[0]].keys()[0]
            data = key[i[0]][key[i[0]].keys()[0]]
            data[np.isnan(data)]=0
            nn = i[0] + 1
            ngr = str(gr)+str(nn)
            subplot(int(ngr))
            subplots_adjust(left=0.125, bottom=0.1, right=0.9, top=0.9, \
                            wspace=0.2, hspace=0.5)
            x_p = data[0][np.where(data[1]>=0)[0]]
            y_p = data[1][np.where(data[1]>=0)[0]]
            x_n = data[0][np.where(data[1]<0)[0]]
            y_n = data[1][np.where(data[1]<0)[0]]
            markerline, stemlines, baseline = stem(x_p, y_p, 'r-')
            setp(markerline, 'markerfacecolor', 'b')
            setp(baseline, 'color', 'r', 'linewidth', 2)
            setp(stemlines, 'linewidth', 1)
            markerline, stemlines, baseline = stem(x_n, y_n, 'b-')
            setp(markerline, 'markerfacecolor', 'b')
            setp(baseline, 'color', 'r', 'linewidth', 2)
            setp(stemlines, 'linewidth', 1)
            setp(gca(), 'ylabel', ylabel)
            setp(gca(), 'title', 'Climate Indices : '+str(ylabel))
            grid()
        setp(gca(), 'xlabel', 'Year')
        #if time_min or time_min != "":
        #    setp(gca(), 'xlim', [time_min,time_max])
        fig = name+'.png'
        savefig(fig)
        show()


this line :

        #if time_min or time_min != "":
        #    setp(gca(), 'xlim', [time_min,time_max])


generate this error :




NotImplementedError: 'Not implemented for this type'

function main in Climate.py at line 178
Climate().multi_stem_plot(md, 'Climate Indices', data_min, data_max)
function multi_stem_plot in Climate.py at line 128
setp(gca(), 'xlim', [time_min,time_max])
function setp in pyplot.py at line 235
ret = _setp(*args, **kwargs)
function setp in artist.py at line 1209
ret.extend( [func(val)] )
function set_xlim in axes.py at line 2439
left, right = mtransforms.nonsingular(left, right, increasing=False)
function nonsingular in transforms.py at line 2282
if (not np.isfinite(vmin)) or (not np.isfinite(vmax)):

While this function works for a single plot :

    def stem_plot(self, data, name, time_min="", time_max=""):
        """ doc """
        data[np.isnan(data)]=0
        x_p = data[0][np.where(data[1]>=0)[0]]
        y_p = data[1][np.where(data[1]>=0)[0]]
        x_n = data[0][np.where(data[1]<0)[0]]
        y_n = data[1][np.where(data[1]<0)[0]]
        markerline, stemlines, baseline = stem(x_p, y_p, 'r-')
        setp(markerline, 'markerfacecolor', 'b')
        setp(baseline, 'color', 'r', 'linewidth', 2)
        setp(stemlines, 'linewidth', 1)
        markerline, stemlines, baseline = stem(x_n, y_n, 'b-')
        setp(markerline, 'markerfacecolor', 'b')
        setp(baseline, 'color', 'r', 'linewidth', 2)
        setp(stemlines, 'linewidth', 1)
        grid()
        if time_min or time_min != "":
            setp(gca(), 'xlim', [time_min,time_max])
        setp(gca(), 'xlabel', 'Year', 'ylabel', name)
        fig = name+'.png'
        savefig(fig)
        print 'indicator : ', name
        show(




Have you any clue on how to fix my error ?

Many thanks!




------------------------------------------------------------------------------
RSA&#174; Conference 2012
Save $700 by Nov 18
Register now&#33;
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to