Пример #1
0
    def add__colorline( self, xAxis=None, yAxis    =None , label =None, alpha     =None, \
                        linestyle  =None, linewidth=None , marker=None, markersize=None, \
                        color      =None, cmap     ="jet", norm  =plt.Normalize(0.0, 1.0) ):

        # ------------------------------------------------- #
        # --- 引数チェック                              --- #
        # ------------------------------------------------- #
        if (yAxis is None): yAxis = self.yAxis
        if (xAxis is None): xAxis = self.xAxis
        if (yAxis is None): sys.exit(" [add__colorline] yAxis == ?? ")
        if (xAxis is None): xAxis = np.arange(yAxis.size)  # - インデックス代用 - #
        if (label is None): label = " " * self.config["leg_labelLength"]
        if (alpha is None): alpha = self.config["plt_alpha"]
        if (linestyle is None): linestyle = self.config["plt_linestyle"]
        if (linewidth is None): linewidth = self.config["plt_linewidth"]
        if (marker is None): marker = self.config["plt_marker"]
        if (markersize is None): markersize = self.config["plt_markersize"]

        # ------------------------------------------------- #
        # --- フィルタリング                            --- #
        # ------------------------------------------------- #
        Filtered = gfl.generalFilter(xAxis=xAxis,
                                     yAxis=yAxis,
                                     config=self.config)
        xAxis, yAxis = Filtered["xAxis"], Filtered["yAxis"]

        # ------------------------------------------------- #
        # --- make & check color_array                  --- #
        # ------------------------------------------------- #
        if (color is None):
            color = np.linspace(0.0, 1.0, len(xAxis))
        if (not (hasattr(color, "__iter__"))):
            color = np.array([color])
        if ((np.min(color) < 0.0) or (np.max(color) > 1.0)):
            print(
                "[add__colorline @ plot1D.py] color range exceeds [0,1] :: Normalize.... "
            )
            color = (color - np.min(color)) / (np.max(color) - np.min(color))

        # ------------------------------------------------- #
        # --- 軸設定                                    --- #
        # ------------------------------------------------- #
        self.xAxis = xAxis
        self.yAxis = yAxis
        color = np.asarray(color)
        points = np.array([xAxis, yAxis]).T.reshape(-1, 1, 2)
        segments = np.concatenate([points[:-1], points[1:]], axis=1)
        self.update__DataRange(xAxis=xAxis, yAxis=yAxis)
        self.set__axis()
        # ------------------------------------------------- #
        # --- プロット 追加                             --- #
        # ------------------------------------------------- #
        import matplotlib.collections as mcoll
        lc = mcoll.LineCollection(segments,
                                  array=color,
                                  cmap=cmap,
                                  norm=norm,
                                  linewidth=linewidth,
                                  alpha=alpha)
        self.ax1.add_collection(lc)
Пример #2
0
 def add__plot( self, xAxis=None, yAxis=None, label=None, color=None, alpha=None, \
                linestyle=None, linewidth=None, \
                marker=None, markersize=None, markerwidth=None ):
     # ------------------------------------------------- #
     # --- 引数チェック                              --- #
     # ------------------------------------------------- #
     if (yAxis is None): yAxis = self.yAxis
     if (xAxis is None): xAxis = self.xAxis
     if (yAxis is None): sys.exit(" [add__plot] yAxis == ?? ")
     if (xAxis is None): xAxis = np.arange(yAxis.size)  # - インデックス代用 - #
     if (label is None): label = ' ' * self.config["leg_labelLength"]
     if (color is None): color = self.config["plt_color"]
     if (alpha is None): alpha = self.config["plt_alpha"]
     if (linestyle is None): linestyle = self.config["plt_linestyle"]
     if (linewidth is None): linewidth = self.config["plt_linewidth"]
     if (marker is None): marker = self.config["plt_marker"]
     if (markersize is None): markersize = self.config["plt_markersize"]
     if (markerwidth is None): markerwidth = self.config["plt_markerwidth"]
     # ------------------------------------------------- #
     # --- フィルタリング                            --- #
     # ------------------------------------------------- #
     Filtered = gfl.generalFilter(xAxis=xAxis,
                                  yAxis=yAxis,
                                  config=self.config)
     xAxis, yAxis = Filtered["xAxis"], Filtered["yAxis"]
     if (self.config["plt_colorStack"] is not None):
         color = (self.config["plt_colorStack"]).pop(0)
     # ------------------------------------------------- #
     # --- 軸設定                                    --- #
     # ------------------------------------------------- #
     self.xAxis = xAxis
     self.yAxis = yAxis
     self.update__DataRange(xAxis=xAxis, yAxis=yAxis)
     self.set__axis()
     # ------------------------------------------------- #
     # --- プロット 追加                             --- #
     # ------------------------------------------------- #
     self.ax1.plot( xAxis, yAxis , \
                    color =color , linestyle =linestyle , \
                    label =label , linewidth =linewidth , \
                    marker=marker, markersize=markersize, \
                    markeredgewidth=markerwidth, alpha =alpha   )
Пример #3
0
    def add__plot_ax2(self, xAxis=None, yAxis=None, label=''):

        # ------------------------------------------------- #
        # --- 引数チェック                              --- #
        # ------------------------------------------------- #
        if (self.nAxis == 1): self.ax2 = self.ax1.twinx()
        if (yAxis is None): sys.exit(" [add__plot_ax2] yAxis == ?? ")
        if (xAxis is None): xAxis = np.arange(yAxis.size)  # -- インデックス代用 -- #

        # ------------------------------------------------- #
        # --- フィルタリング                            --- #
        # ------------------------------------------------- #
        Filtered = gfl.generalFilter(xAxis=xAxis,
                                     yAxis=yAxis,
                                     config=self.config)
        xAxis, yAxis = Filtered["xAxis"], Filtered["yAxis"]
        # ------------------------------------------------- #
        # --- プロット ( 2軸目 )                        --- #
        # ------------------------------------------------- #
        self.ax2.plot(xAxis, yAxis, alpha=0.95, label=label)
Пример #4
0
    def add__errorbar( self, xAxis=None, yAxis=None, xerr=None, yerr=None, \
                       capsize=None, capthick=None, fmt="none", \
                       label=None, color=None, alpha=None, \
                       linestyle=None, linewidth=None, marker=None, markersize=None ):
        # ------------------------------------------------- #
        # --- 引数チェック                              --- #
        # ------------------------------------------------- #
        if (yAxis is None): yAxis = self.yAxis
        if (xAxis is None): xAxis = self.xAxis
        if (yAxis is None): sys.exit(" [add__errorbar] yAxis == ?? ")
        if (xAxis is None): xAxis = np.arange(yAxis.size)  # - インデックス代用 - #
        if (color is None): color = self.config["plt_color"]
        if (alpha is None): alpha = self.config["plt_alpha"]
        if (linewidth is None): linewidth = self.config["plt_linewidth"] * 0.8
        if (linestyle is None): linestyle = self.config["plt_linestyle"]
        if (marker is None): marker = self.config["plt_marker"]
        if (markersize is None): markersize = self.config["plt_markersize"]
        if (capthick is None): capthick = self.config["plt_error_capthick"]
        if (capsize is None): capsize = self.config["plt_error_capsize"]

        if ((xerr is None) and (yerr is None)):
            sys.exit("[add__errorbar] xerr=None & yerr=None ")
        # ------------------------------------------------- #
        # --- フィルタリング                            --- #
        # ------------------------------------------------- #
        Filtered = gfl.generalFilter(xAxis=xAxis,
                                     yAxis=yAxis,
                                     config=self.config)
        xAxis, yAxis = Filtered["xAxis"], Filtered["yAxis"]
        if (self.config["plt_colorStack"] is not None):
            color = (self.config["plt_colorStack"]).pop(0)
        # ------------------------------------------------- #
        # --- プロット 追加                             --- #
        # ------------------------------------------------- #
        self.ax1.errorbar( xAxis, yAxis, xerr=xerr, yerr=yerr, \
                           fmt=fmt, capsize=capsize, capthick=capthick, \
                           ecolor=color , elinestyle=linestyle, elinewidth=linewidth , \
                           marker=marker, markersize=markersize,  \
                           alpha=alpha )