Example #1
0
    def _plot_helper(self, x, y, *args, **kwargs):
        if not hasattr(y, "dims"):
            return Axes.plot(self, x, y, *args, **kwargs)
        if x.ndim == 1 and y.ndim == 1:
            return Axes.plot(self, x, y, *args, **kwargs)
        else:
            return Axes.plot(self, remove_tail(x), remove_tail(y), *args,
                             **kwargs)

            Ns = y.shape[1:4]
            kw = kwargs.copy()
            lines = []
            if len(Ns) == 1:
                C = zip(itertools.cycle(self.colorcycle), range(Ns[0]))
                for c, i in C:
                    #kw.update(dict(color=c))
                    if hasattr(x, "dims") and (get_dims_names(x)
                                               == get_dims_names(y)):
                        xx = x[:, i].squeeze()
                    else:
                        xx = x
                    lines.extend(
                        Axes.plot(self, xx, remove_tail(y[:, i]), *args, **kw))
            elif len(Ns) == 2:
                C = zip(itertools.cycle(self.colorcycle), range(Ns[0]))
                M = zip(itertools.cycle(self.markercycle), range(Ns[1]))
                for c, i in C:
                    for m, j in M:
                        if hasattr(x, "dims") and (get_dims_names(x)
                                                   == get_dims_names(y)):
                            xx = x[:, i, j].squeeze()
                        else:
                            xx = x
                        #kw.update(dict(color=c, marker=m))
                        lines.extend(
                            Axes.plot(self, xx, remove_tail(y[:, i, j]), *args,
                                      **kw))
            elif len(Ns) > 2:
                C = zip(itertools.cycle(self.colorcycle), range(Ns[0]))
                M = zip(itertools.cycle(self.markercycle), range(Ns[1]))
                L = zip(itertools.cycle(self.linecycle), range(Ns[2]))
                for c, i in C:
                    for m, j in M:
                        for l, k in L:
                            if hasattr(x, "dims") and (get_dims_names(x)
                                                       == get_dims_names(y)):
                                xx = x[:, i, j, k].squeeze()
                            else:
                                xx = x
                            #kw.update(dict(color=c, marker=m, line=l))
                            lines.extend(
                                Axes.plot(self, xx, remove_tail(y[:, i, j, k]),
                                          *args, **kw))
            return lines
Example #2
0
    def _plot_helper(self, x, y, *args, **kwargs):
        if not hasattr(y, "dims"):
            return Axes.plot(self, x, y, *args, **kwargs)
        if x.ndim == 1 and y.ndim == 1:
            return Axes.plot(self, x, y, *args, **kwargs)
        else:
            return Axes.plot(self, remove_tail(x), remove_tail(y), *args, **kwargs)

            Ns = y.shape[1:4]
            kw = kwargs.copy()
            lines = []
            if len(Ns) == 1:
                C = zip(itertools.cycle(self.colorcycle), range(Ns[0]))
                for c, i in C:
                    #kw.update(dict(color=c))
                    if hasattr(x, "dims") and (get_dims_names(x) ==
                                               get_dims_names(y)):
                        xx = x[:, i].squeeze()
                    else:
                        xx = x
                    lines.extend(Axes.plot(self, xx, remove_tail(y[:, i]),
                                           *args, **kw))
            elif len(Ns) == 2:
                C = zip(itertools.cycle(self.colorcycle), range(Ns[0]))
                M = zip(itertools.cycle(self.markercycle), range(Ns[1]))
                for c, i in C:
                    for m, j in M:
                        if hasattr(x, "dims") and (get_dims_names(x) ==
                                                   get_dims_names(y)):
                            xx = x[:, i, j].squeeze()
                        else:
                            xx = x
                        #kw.update(dict(color=c, marker=m))
                        lines.extend(Axes.plot(self, xx,
                                               remove_tail(y[:, i, j]),
                                               *args, **kw))
            elif len(Ns) > 2:
                C = zip(itertools.cycle(self.colorcycle), range(Ns[0]))
                M = zip(itertools.cycle(self.markercycle), range(Ns[1]))
                L = zip(itertools.cycle(self.linecycle), range(Ns[2]))
                for c, i in C:
                    for m, j in M:
                        for l, k in L:
                            if hasattr(x, "dims") and (get_dims_names(x) ==
                                                       get_dims_names(y)):
                                xx = x[:, i, j, k].squeeze()
                            else:
                                xx = x
                            #kw.update(dict(color=c, marker=m, line=l))
                            lines.extend(Axes.plot(self, xx,
                                                   remove_tail(y[:, i, j, k]),
                                                   *args, **kw))
            return lines
Example #3
0
    def plot(self, *args, **kwargs):
        projection = self.name
        vars = args[:2]
        args = args[2:]
        if len(vars) == 2 and isinstance(vars[1], (str, unicode)):
            args = (vars[1], ) + args
            vars = vars[:1]

        if ((len(vars) == 1 and isinstance(vars[0], hfarray)
             and len(vars[0].dims) >= 1)):
            y = vars[0]
            x = hfarray(y.dims[0])
            vars = (x, y)

        if len(vars) == 1:
            y = vars[0]
            if projection in _projfun:
                x, y = _projfun[projection](None, y)
                return Axes.plot(self, y, *args, **kwargs)
            elif np.iscomplexobj(y):
                return Axes.plot(self, y.real, y.imag, *args, **kwargs)
            else:
                return Axes.plot(self, y, *args, **kwargs)
        elif len(vars) == 2:
            x = vars[0]
            y = remove_tail(vars[1])

            if projection in _projfun:
                x, y = _projfun[projection](x, y)
                lines = Axes.plot(self, x, y, *args, **kwargs)
            elif np.iscomplexobj(y):
                lines = Axes.plot(self, y.real, y.imag, *args, **kwargs)
            else:
                lines = Axes.plot(self, x, y, *args, **kwargs)


#            if xunit:
#                self.set_xlabel_unit(xunit)
#            if yunit:
#                self.set_ylabel_unit(yunit)
            return lines
        else:
            raise Exception("Missing plot data")
Example #4
0
    def plot(self, *args, **kwargs):
        projection = self.name
        vars = args[:2]
        args = args[2:]
        if len(vars) == 2 and isinstance(vars[1], (str, unicode)):
            args = (vars[1],) + args
            vars = vars[:1]

        if ((len(vars) == 1 and
             isinstance(vars[0], hfarray) and
             len(vars[0].dims) >= 1)):
            y = vars[0]
            x = hfarray(y.dims[0])
            vars = (x, y)

        if len(vars) == 1:
            y = vars[0]
            if projection in _projfun:
                x, y = _projfun[projection](None, y)
                return Axes.plot(self, y, *args, **kwargs)
            elif np.iscomplexobj(y):
                return Axes.plot(self, y.real, y.imag, *args, **kwargs)
            else:
                return Axes.plot(self, y, *args, **kwargs)
        elif len(vars) == 2:
            x = vars[0]
            y = remove_tail(vars[1])

            if projection in _projfun:
                x, y = _projfun[projection](x, y)
                lines = Axes.plot(self, x, y, *args, **kwargs)
            elif np.iscomplexobj(y):
                lines = Axes.plot(self, y.real, y.imag, *args, **kwargs)
            else:
                lines = Axes.plot(self, x, y, *args, **kwargs)
#            if xunit:
#                self.set_xlabel_unit(xunit)
#            if yunit:
#                self.set_ylabel_unit(yunit)
            return lines
        else:
            raise Exception("Missing plot data")