Example #1
0
    def __init__(self,
                 title='title',
                 xlabel=None,
                 xs=None,
                 ylable=None,
                 yscale='linear',
                 ys=None,
                 ylim=None,
                 fName='test.pdf'):
        self.linestyles = ['-', '--', '-.', ':']
        self.indexLineStyle = 0
        self.dashess = [[2, 2, 2, 2], [4, 4, 4, 4], [6, 6, 6, 6], [6, 2, 6, 2],
                        [10, 5, 10, 5], [12, 12, 12, 12]]
        self.indexDash = 0

        self.title = title

        self.xlabel = xlabel
        self.xs = xs

        self.ylable = ylable
        self.yscale = yscale
        self.ys = ys
        self.ylim = ylim

        self.fpath = PathUtility.figure_path() + fName

        # self.fig = plt.figure(random.randint(1, 10000), figsize=(10.1023, 6.5), tight_layout=True)
        self.fig = plt.figure(random.randint(1, 10000),
                              figsize=(10, 8),
                              tight_layout=True)
        self.fig.canvas.set_window_title(title)

        plt.rcParams['font.size'] = 20
        self.ax = self.fig.add_subplot(111)
Example #2
0
    def __init__(self,
                 numBar,
                 title=None,
                 widthBar=0.14,
                 spanBars=0.03,
                 xlabel=None,
                 xTxts=None,
                 xTxtY=None,
                 xRotateAngle=0,
                 ylabel=None,
                 yscale='linear',
                 ys=None,
                 ylim=None,
                 loc=1,
                 fName=None):
        self.hatchxes = ['x', '.', '+', 'O']
        self.hatchIndex = 0

        if title == None: self.title = fName

        self.numBar = numBar
        self.widthBar = widthBar
        self.spanBars = spanBars  # 两个相邻bar之间相隔的宽度
        self.spanXTick = 5 / (len(xTxts) + 1)
        self.xs = [self.spanXTick * i for i in range(len(xTxts) + 2)]
        self.baseStartXOfBar = self.xs[1] - (widthBar * numBar + spanBars *
                                             (numBar - 1)) / 2
        self.spanNextBar = widthBar + spanBars  # 两个相邻bar的左边x坐标之差

        self.xlabel = xlabel
        self.xTxts = xTxts
        self.xTxtY = xTxtY  # 设置x轴的txt所在y
        self.xRotateAngle = xRotateAngle

        self.ylabel = ylabel
        self.yscale = yscale
        self.ys = ys
        self.ylim = ylim

        self.loc = loc

        self.fpath = PathUtility.figure_path() + fName

        # figure设置
        # self.fig = plt.figure(random.randint(1, 10000), figsize=(10.1023, 6.5), tight_layout=True)
        self.fig = plt.figure(random.randint(1, 10000),
                              figsize=(10, 8),
                              tight_layout=True)
        # self.fig = plt.figure(random.randint(1, 10000), figsize=(8, 6), tight_layout=True)
        self.fig.canvas.set_window_title(self.title)
        # 设置全局字体大小
        plt.rcParams['font.size'] = 25
        self.ax = self.fig.add_subplot(111)
Example #3
0
    def __init__(self,
                 fig=None,
                 xs=None,
                 ys=None,
                 xlim=None,
                 ylim=None,
                 title='title',
                 pathBgImg=None,
                 yscale='linear',
                 showXY=True,
                 markerscale=1,
                 fName='test.pdf'):

        plt.rcParams['axes.ymargin'] = 0
        plt.rcParams['axes.autolimit_mode'] = 'round_numbers'

        if fig is None:
            # self.fig = plt.figure(random.randint(1, 10000), figsize=(10.1023, 6.5), tight_layout=True)
            self.fig = plt.figure(random.randint(1, 10000),
                                  figsize=(8, 6.5),
                                  tight_layout=True)
        else:
            self.fig = fig
        # self.fig = plt.figure(random.randint(1, 10000))
        self.fig.canvas.set_window_title(title)

        # #  = None
        # if yscale != None:
        #     self.yscale = yscale
        # else:
        #     self.yscale = 'linear'
        self.markerscale = markerscale
        self.yscale = yscale
        self.xs = xs
        self.ys = ys
        self.xlim = xlim
        self.ylim = ylim
        self.pathBgImg = pathBgImg

        self.showXY = showXY

        self.fpath = PathUtility.figure_path() + fName

        plt.rcParams['font.size'] = 20
        plt.subplots_adjust(left=0, right=1, bottom=0, top=1)
        plt.margins(0)
        if fig is None:
            self.ax = self.fig.add_subplot(111)