示例#1
0
文件: analysis.py 项目: jvcarli/PyTTa
    def plot_bars(self,
                  dataLabel: str = None,
                  errorLabel: str = None,
                  xLabel: str = None,
                  yLabel: str = None,
                  yLim: list = None,
                  xLim: list = None,
                  title: str = None,
                  decimalSep: str = ',',
                  barWidth: float = 0.75,
                  errorStyle: str = None,
                  forceZeroCentering: bool = False,
                  overlapBars: bool = False,
                  color: list = None):
        """Plot the analysis data in fractinal octave bands.

        Parameters (default), (type):
        -----------------------------

            * dataLabel ('Analysis type [unit]'), (str):
                legend label for the current data

            * errorLabel ('Error'), (str):
                legend label for the current data error

            * xLabel ('Time [s]'), (str):
                x axis label.

            * yLabel ('Amplitude'), (str):
                y axis label.

            * yLim (), (list):
                inferior and superior limits.

                >>> yLim = [-100, 100]

            * xLim (), (list):
                bands limits.

                >>> xLim = [100, 10000]

            * title (), (str):
                plot title

            * decimalSep (','), (str):
                may be dot or comma.

                >>> decimalSep = ',' # in Brazil

            * barWidth (0.75), float:
                width of the bars from one fractional octave band.
                0 < barWidth < 1.

            * errorStyle ('standard'), str:
                error curve style. May be 'laza' or None/'standard'.

            * forceZeroCentering ('False'), bool:
                force centered bars at Y zero.

            * overlapBars ('False'), bool:
                overlap bars. No side by side bars of different data.

            * color (None), list:
                list containing the color of each Analysis.


        Return:
        --------

            matplotlib.figure.Figure object.
        """
        if dataLabel is not None:
            self.dataLabel = dataLabel

        if errorLabel is not None:
            self.errorLabel = errorLabel

        if xLabel is not None:
            self.barsXLabel = xLabel
        else:
            if hasattr(self, 'barsXLabel'):
                if self.barsXLabel is not None:
                    xLabel = self.barsXLabel

        if yLabel is not None:
            self.barsYLabel = yLabel
        else:
            if hasattr(self, 'barsYLabel'):
                if self.barsYLabel is not None:
                    yLabel = self.barsYLabel

        if title is not None:
            self.barsTitle = title
        else:
            if hasattr(self, 'barsTitle'):
                if self.barsTitle is not None:
                    title = self.barsTitle

        fig = plot.bars((self, ), xLabel, yLabel, yLim, xLim, self.title,
                        decimalSep, barWidth, errorStyle, forceZeroCentering,
                        overlapBars, color)
        return fig
示例#2
0
文件: functions.py 项目: ErVuL/PyTTa
def plot_bars(*analyses,
              xLabel: str = None,
              yLabel: str = None,
              yLim: list = None,
              xLim: list = None,
              title: str = None,
              decimalSep: str = ',',
              barWidth: float = 0.75,
              errorStyle: str = None,
              forceZeroCentering: bool = False,
              overlapBars: bool = False,
              color: list = None):
    """Plot the analysis data in fractinal octave bands.

    Parameters (default), (type):
    -----------------------------

        * analyses (), (SignalObj):
            non-keyworded input arguments with N SignalObjs.

        * xLabel ('Time [s]'), (str):
            x axis label.

        * yLabel ('Amplitude'), (str):
            y axis label.

        * yLim (), (list):
            inferior and superior limits.

            >>> yLim = [-100, 100]

        * xLim (), (list):
            bands limits.

            >>> xLim = [100, 10000]

        * title (), (str):
            plot title

        * decimalSep (','), (str):
            may be dot or comma.

            >>> decimalSep = ',' # in Brazil

        * barWidth (0.75), float:
            width of the bars from one fractional octave band.
            0 < barWidth < 1.

        * errorStyle ('standard'), str:
            error curve style. May be 'laza' or None/'standard'.

        * forceZeroCentering ('False'), bool:
            force centered bars at Y zero.

        * overlapBars ('False'), bool:
            overlap bars. No side by side bars of different data.

        * color (None), list:
            list containing the color of each Analysis.


    Return:
    --------

        matplotlib.figure.Figure object.
    """

    analyses = _remove_non_(Analysis, analyses, msgPrefix='plot_bars:')
    if len(analyses) > 0:
        fig = plot.bars(analyses, xLabel, yLabel, yLim, xLim, title,
                        decimalSep, barWidth, errorStyle, forceZeroCentering,
                        overlapBars, color)
        return fig
    else:
        return