def mouseDoubleClickEvent(self, event):
        if not self.button_vcursor.isChecked():
            vals = []
            result = []
            inv = self.ax.transData.inverted()
            inv2 = self.ax2.transData.inverted()
            try:
                [time_ax, val_ax] = inv.transform((event.x(), self.frameSize().height() - event.y()))
            except IndexError:
                [time_ax, val_ax] = transformCoord2Log((event.x(), self.frameSize().height() - event.y()), self.ax,
                                                       self.ax2)
            t0, tmax = self.ax.get_xlim()

            for ax in self.fig.get_axes():
                for lines in ax.get_lines():
                    if self.isinDict(lines):
                        ind_t0 = indFinder(t0, lines.get_xdata())
                        ind_tmax = indFinder(tmax, lines.get_xdata())
                        step = 1 + (ind_tmax - ind_t0) / 400
                        ind = indFinder(time_ax, lines.get_xdata())

                        for i in range(ind - step, ind + step):
                            if i >= 0 and i < len(lines.get_xdata()):
                                try:
                                    new_coord = ax.transData.transform((lines.get_xdata()[i], lines.get_ydata()[i]))
                                except TypeError:
                                    new_coord = transformCoord2Log((lines.get_xdata()[i], lines.get_ydata()[i]),
                                                                   self.ax, self.ax2, inv=True)
                                if new_coord is not None:
                                    vals.append(np.sqrt((new_coord[0] - event.x()) ** 2 + (
                                        new_coord[1] - (self.frameSize().height() - event.y())) ** 2))
                                    result.append([lines.get_xdata()[i], lines.get_ydata()[i], ax, lines.get_label()])

            if result:
                label_point = QLabel(self)
                label_point.setWordWrap(True)
                point = result[np.argmin(vals)]
                txt = "%s \r\n" % point[3]
                if point[2].get_yscale() == "log":
                    txt += "%s \r\n % 0.3e" % (num2date(point[0]).strftime("%d/%m/%Y %H:%M:%S"), point[1])
                else:
                    txt += "%s \r\n % 0.2f" % (num2date(point[0]).strftime("%d/%m/%Y %H:%M:%S"), point[1])

                if label_point.width() + event.x() > self.frameSize().width():
                    label_point.move(event.x() - label_point.width(), event.y() - 16)
                else:
                    label_point.move(event.x(), event.y() - 16)
                line, = point[2].plot(point[0], point[1], 'o', color='k', markersize=4.)

                self.fig.canvas.restore_region(self.background)
                for ax in self.fig.get_axes():
                    for lines in ax.get_lines():
                        ax.draw_artist(lines)
                self.fig.canvas.blit(self.fig.bbox)
                label_point.setText(txt)
                label_point.show()

                timer = QTimer.singleShot(10000, partial(self.hidePoint, line, label_point, point[2]))
    def mouseDoubleClickEvent(self, event):
        if not self.allAxes.keys():
            return
        results = []

        pix_point_x = event.x()
        pix_point_y = self.frameSize().height() - event.y()
        inv = self.allAxes[0].transData.inverted()

        [t_point, __] = inv.transform((pix_point_x, pix_point_y))

        for curve in self.curvesOnAxes:
            ax = curve.getAxes()

            t0, tmax = ax.get_xlim()
            ind_min = indFinder(curve.get_xdata(), t0)
            ind_max = indFinder(curve.get_xdata(), tmax)
            resolution = (ind_max - ind_min) / (self.frameSize().width())
            t_ind = indFinder(curve.get_xdata(), t_point)
            imin, imax = int(t_ind - 4 * resolution), int(t_ind + 4 * resolution) + 1
            imin = 0 if imin < 0 else imin
            imax = len(curve.get_xdata()) if imax >= len(curve.get_xdata()) else imax

            data = [ax.transData.transform((curve.get_xdata()[i], curve.get_ydata()[i])) for i in range(imin, imax)]
            delta = [np.sqrt((x - pix_point_x) ** 2 + (y - pix_point_y) ** 2) for x, y in data]

            results.append((np.argmin(delta) + imin, np.min(delta), curve))

        if not results:
            return
        ind_dist, min_dist, curve = results[np.argmin([mini for argmin, mini, curve in results])]
        valx, valy = curve.get_xdata()[ind_dist], curve.get_ydata()[ind_dist]

        labelPoint = QLabel(self)
        labelPoint.setText('%s \r\n %s : %g' % (num2date(valx).isoformat()[:19], curve.label, valy))
        labelPoint.show()

        offset = 0 if (event.x() + labelPoint.width()) < self.frameSize().width() else labelPoint.width()
        labelPoint.move(event.x() - offset, event.y())

        point, = curve.getAxes().plot(valx, valy, 'o', color='k', markersize=4.)

        curve.getAxes().draw_artist(point)
        self.doBlit()

        extraLine = ExtraLine(point, labelPoint)
        self.plotWindow.extraLines.append(extraLine)

        timer = QTimer.singleShot(6000, partial(self.removeExtraLine, extraLine))
    def updateLimits(self, axes, xdata, scaleY=True, doDraw=False):
        tmin, tmax = axes.get_xlim()

        if np.max(xdata) > (tmax - 0.01 * (tmax - tmin)):
            axes.set_xlim(self.calc_lim(tmin, np.max(xdata), f1=0, f2=0.15))
            doDraw = True

        if scaleY:
            for ax in self.allAxes.values():
                if self.plotWindow.axes2curves[ax]:
                    ymin, ymax = ax.get_ylim()
                    delta = 0.03 * (ymax - ymin)

                    curves = self.plotWindow.axes2curves[ax]
                    indices = [indFinder(curve.get_xdata(), tmin) for curve in curves]

                    newMin = np.min([np.min(curve.get_ydata()[ind:]) for curve, ind in zip(curves, indices)])
                    newMax = np.max([np.max(curve.get_ydata()[ind:]) for curve, ind in zip(curves, indices)])

                    newMin = newMin if newMin < (ymin + delta) else ymin
                    newMax = newMax if newMax > (ymax - delta) else ymax

                    if not (newMin == ymin and newMax == ymax):
                        logy = True if ax.get_yscale() == 'log' else False
                        ax.set_ylim(self.calc_lim(newMin, newMax, logy=logy))
                        doDraw = True

        return doDraw
    def updateLimit(self, bool_draw=False):
        if not bool_draw:
            self.fig.canvas.restore_region(self.background)

        list_tmax = []
        t0, tmax = self.ax.get_xlim()
        for i, ax in enumerate(self.fig.get_axes()):
            list_min_value = []
            list_max_value = []
            for line in ax.lines:
                if not hasattr(self, "linev"):
                    ax.draw_artist(line)
                if self.isinDict(line):
                    ind = indFinder(t0, line.get_xdata())
                    min_value, max_value, max_time = np.min(line.get_ydata()[ind:]), np.max(line.get_ydata()[ind:]), \
                                                     line.get_xdata()[-1]
                    list_tmax.append(max_time)
                    if ax.get_yscale() == "log":
                        list_min_value.append(10 ** (floor(log10(min_value))))
                        list_max_value.append(10 ** (floor(log10(max_value)) + 1))
                    else:
                        list_min_value.append(min_value)
                        list_max_value.append(max_value)
            min_yaxis, max_yaxis = ax.get_ylim()
            if list_min_value and (not (self.toolbar.isZoomed() or self.toolbar.isPanned())):
                if np.max(list_max_value) != np.min(list_min_value):
                    if np.min(list_min_value) < min_yaxis:
                        if ax.get_yscale() == "log":
                            ax.set_ylim(np.min(list_min_value), max_yaxis)
                        else:
                            ax.set_ylim(
                                np.min(list_min_value) - (np.max(list_max_value) - np.min(list_min_value)) * 0.05,
                                max_yaxis)
                        bool_draw = True
                    if np.max(list_max_value) > max_yaxis:
                        if ax.get_yscale() == "log":
                            ax.set_ylim(min_yaxis,
                                        np.max(list_max_value) + (
                                            np.max(list_max_value) - np.min(list_min_value)) * 0.05)
                        else:
                            ax.set_ylim(min_yaxis,
                                        np.max(list_max_value))
                        bool_draw = True

                else:
                    ax.set_ylim(np.min(list_min_value) * 0.95, np.max(list_max_value) * 1.05)
                    bool_draw = True
        if list_tmax:
            if np.max(list_tmax) > tmax and not self.toolbar.isZoomed():
                samp_time = 0.28 * (np.max(list_tmax) - t0)
                self.ax.set_xlim(t0, np.add(np.max(list_tmax), samp_time))
                bool_draw = True

        if bool_draw:
            self.fig.canvas.draw()

        else:
            self.fig.canvas.blit(self.fig.bbox)

        self.onDrawing = False
    def verticalCursor(self, time, display_coord):

        i = 0
        res = []
        self.exceptCursor = False
        if hasattr(self, "linev"):
            try:
                self.fig.canvas.restore_region(self.background)
                self.linev.set_xdata((time, time))
                self.ax.draw_artist(self.linev)
                self.fig.canvas.blit(self.fig.bbox)

            except RuntimeError:
                self.exceptCursor = True
        else:
            self.linev = self.ax.axvline(time, visible=True)

        if not self.exceptCursor:
            for ax in self.fig.get_axes():
                for lines in ax.get_lines():
                    if self.isinDict(lines):
                        try:
                            ind = indFinder(time, lines.get_xdata())
                        except RuntimeError:
                            self.exceptCursor = True
                        except IndexError:
                            ind = len(lines.get_xdata()) - 1
                        if not self.exceptCursor:
                            if i == 0:
                                txt = (num2date(lines.get_xdata()[ind]).strftime("%d/%m/%Y %H:%M:%S") + "\r\n")
                                i += 1

                            if "pressure" in self.dictofline[lines].type and self.dictofline[lines].type[
                                                                             -2:] != "dt":
                                format = "%s : %0.3e \r\n"
                            else:
                                format = "%s : %0.2f \r\n"
                            try:
                                new_coord = ax.transData.transform((lines.get_xdata()[ind], lines.get_ydata()[ind]))
                            except TypeError:
                                new_coord = transformCoord2Log((lines.get_xdata()[ind], lines.get_ydata()[ind]),
                                                               self.ax, self.ax2, inv=True)

                            res.append([format, lines.get_label(), lines.get_ydata()[ind], new_coord[1]])
            res.sort(key=lambda row: row[3])
            txt += "".join(val[0] % (val[1], val[2]) for val in reversed(res))

            if not self.exceptCursor:
                if self.label_cursor.width() + display_coord[0] > self.frameSize().width():
                    self.label_cursor.move(display_coord[0] - self.label_cursor.width(), 200)
                else:
                    self.label_cursor.move(display_coord[0], 200)

                self.label_cursor.setText(txt)
                self.label_cursor.show()
    def buildText(self, vLine, tpoint, curves):

        txt = (num2date(tpoint).isoformat()[:19] + "\r\n")
        toSort = []

        for curve in curves:
            ind = indFinder(curve.get_xdata(), tpoint)
            x, y = curve.get_xdata()[ind], curve.get_ydata()[ind]
            pix_x, pix_y = curve.getAxes().transData.transform((x, y))
            toSort.append((pix_y, y, curve.label))

        toSort.sort(key=lambda row: row[0])
        txt += "\r\n".join(["%s : %g " % (label, valy) for pix, valy, label in reversed(toSort)])

        vLine.label.setText(txt)
        vLine.label.show()

        return (vLine.label.height()) / 2
    def addLegend(self):
        if not self.allAxes.items():
            return

        t0, tmax = self.allAxes[0].get_xlim()

        for axesId in self.primaryAxes:
            cvs = []
            for twin in range(2):
                try:
                    ax = self.allAxes[axesId + twin]
                    cvs += self.plotWindow.axes2curves[ax]
                except KeyError:
                    pass

            try:
                self.allAxes[axesId].get_legend().remove()
            except (AttributeError, KeyError):
                pass

            if cvs:
                indices = [indFinder(curve.get_xdata(), tmax) for curve in cvs]
                vals = [(curve.get_xdata()[ind], curve.get_ydata()[ind]) for curve, ind in zip(cvs, indices)]

                coords = [curve.getAxes().transData.transform((x, y)) for curve, (x, y) in zip(cvs, vals)]

                toSort = [(pix_y, curve.line, curve.label) for curve, (pix_x, pix_y) in zip(cvs, coords)]

                toSort.sort(key=lambda row: row[0])

                lns = [line for pix, line, label in reversed(toSort)]
                labs = [line.get_label() for line in lns]

                size = 8.5 - 0.12 * len(lns)

                self.allAxes[axesId].legend(lns, labs, loc='best', prop={'size': size})
    def mouseDoubleClickEvent(self, event):
        if not self.button_vcursor.isChecked():
            vals = []
            result = []
            inv = self.ax.transData.inverted()
            inv2 = self.ax2.transData.inverted()
            try:
                [time_ax, val_ax] = inv.transform(
                    (event.x(), self.frameSize().height() - event.y()))
            except IndexError:
                [time_ax, val_ax] = transformCoord2Log(
                    (event.x(), self.frameSize().height() - event.y()),
                    self.ax, self.ax2)
            t0, tmax = self.ax.get_xlim()

            for ax in self.fig.get_axes():
                for lines in ax.get_lines():
                    if self.isinDict(lines):
                        ind_t0 = indFinder(t0, lines.get_xdata())
                        ind_tmax = indFinder(tmax, lines.get_xdata())
                        step = 1 + (ind_tmax - ind_t0) / 400
                        ind = indFinder(time_ax, lines.get_xdata())

                        for i in range(ind - step, ind + step):
                            if i >= 0 and i < len(lines.get_xdata()):
                                try:
                                    new_coord = ax.transData.transform(
                                        (lines.get_xdata()[i],
                                         lines.get_ydata()[i]))
                                except TypeError:
                                    new_coord = transformCoord2Log(
                                        (lines.get_xdata()[i],
                                         lines.get_ydata()[i]),
                                        self.ax,
                                        self.ax2,
                                        inv=True)
                                if new_coord is not None:
                                    vals.append(
                                        np.sqrt((new_coord[0] - event.x())**2 +
                                                (new_coord[1] -
                                                 (self.frameSize().height() -
                                                  event.y()))**2))
                                    result.append([
                                        lines.get_xdata()[i],
                                        lines.get_ydata()[i], ax,
                                        lines.get_label()
                                    ])

            if result:
                label_point = QLabel(self)
                label_point.setWordWrap(True)
                point = result[np.argmin(vals)]
                txt = "%s \r\n" % point[3]
                if point[2].get_yscale() == "log":
                    txt += "%s \r\n % 0.3e" % (num2date(
                        point[0]).strftime("%d/%m/%Y %H:%M:%S"), point[1])
                else:
                    txt += "%s \r\n % 0.2f" % (num2date(
                        point[0]).strftime("%d/%m/%Y %H:%M:%S"), point[1])

                if label_point.width() + event.x() > self.frameSize().width():
                    label_point.move(event.x() - label_point.width(),
                                     event.y() - 16)
                else:
                    label_point.move(event.x(), event.y() - 16)
                line, = point[2].plot(point[0],
                                      point[1],
                                      'o',
                                      color='k',
                                      markersize=4.)

                self.fig.canvas.restore_region(self.background)
                for ax in self.fig.get_axes():
                    for lines in ax.get_lines():
                        ax.draw_artist(lines)
                self.fig.canvas.blit(self.fig.bbox)
                label_point.setText(txt)
                label_point.show()

                timer = QTimer.singleShot(
                    10000, partial(self.hidePoint, line, label_point,
                                   point[2]))
    def verticalCursor(self, time, display_coord):

        i = 0
        res = []
        self.exceptCursor = False
        if hasattr(self, "linev"):
            try:
                self.fig.canvas.restore_region(self.background)
                self.linev.set_xdata((time, time))
                self.ax.draw_artist(self.linev)
                self.fig.canvas.blit(self.fig.bbox)

            except RuntimeError:
                self.exceptCursor = True
        else:
            self.linev = self.ax.axvline(time, visible=True)

        if not self.exceptCursor:
            for ax in self.fig.get_axes():
                for lines in ax.get_lines():
                    if self.isinDict(lines):
                        try:
                            ind = indFinder(time, lines.get_xdata())
                        except RuntimeError:
                            self.exceptCursor = True
                        except IndexError:
                            ind = len(lines.get_xdata()) - 1
                        if not self.exceptCursor:
                            if i == 0:
                                txt = (num2date(lines.get_xdata()[ind]).
                                       strftime("%d/%m/%Y %H:%M:%S") + "\r\n")
                                i += 1

                            if "pressure" in self.dictofline[
                                    lines].type and self.dictofline[
                                        lines].type[-2:] != "dt":
                                format = "%s : %0.3e \r\n"
                            else:
                                format = "%s : %0.2f \r\n"
                            try:
                                new_coord = ax.transData.transform(
                                    (lines.get_xdata()[ind],
                                     lines.get_ydata()[ind]))
                            except TypeError:
                                new_coord = transformCoord2Log(
                                    (lines.get_xdata()[ind],
                                     lines.get_ydata()[ind]),
                                    self.ax,
                                    self.ax2,
                                    inv=True)

                            res.append([
                                format,
                                lines.get_label(),
                                lines.get_ydata()[ind], new_coord[1]
                            ])
            res.sort(key=lambda row: row[3])
            txt += "".join(val[0] % (val[1], val[2]) for val in reversed(res))

            if not self.exceptCursor:
                if self.label_cursor.width(
                ) + display_coord[0] > self.frameSize().width():
                    self.label_cursor.move(
                        display_coord[0] - self.label_cursor.width(), 200)
                else:
                    self.label_cursor.move(display_coord[0], 200)

                self.label_cursor.setText(txt)
                self.label_cursor.show()
    def updateStyle(self):
        lns = []
        labs = []
        vmax = []
        self.ax.set_xlabel('Time')
        for i, ax in enumerate(self.fig.get_axes()):
            if ax.get_lines():
                ax.set_ylabel(self.dictofline[ax.get_lines()[0]].ylabel,
                              color=self.dictofline[ax.get_lines()[0]].color)
                for tick in ax.yaxis.get_major_ticks():
                    if i == 0:
                        tick.label1On = True
                        tick.label2On = False
                        tick.label1.set_color(
                            color=self.dictofline[ax.get_lines()[0]].color)
                        self.ax2.grid(which='major', alpha=0.0)
                        ax.grid(which='major',
                                alpha=0.5,
                                color=self.dictofline[ax.get_lines()[0]].color)
                        ax.grid(which='minor',
                                alpha=0.25,
                                color=self.dictofline[ax.get_lines()[0]].color,
                                linestyle='--')
                    elif i == 1:
                        tick.label1On = False
                        tick.label2On = True
                        tick.label2.set_color(
                            color=self.dictofline[ax.get_lines()[0]].color)
                        ax.grid(which='major',
                                alpha=1.0,
                                color=self.dictofline[ax.get_lines()[0]].color,
                                linestyle='dashdot')
                for lines in ax.get_lines():
                    if self.isinDict(lines):
                        t0, tmax = self.ax.get_xlim()
                        ind = indFinder(tmax, lines.get_xdata())
                        try:
                            new_coord = ax.transData.transform(
                                (lines.get_xdata()[ind],
                                 lines.get_ydata()[ind]))
                        except TypeError:
                            new_coord = transformCoord2Log(
                                (lines.get_xdata()[ind],
                                 lines.get_ydata()[ind]),
                                self.ax,
                                self.ax2,
                                inv=True)

                        vmax.append([new_coord[1], lines.get_label(), lines])
                        self.setLineStyle(lines)

                if ax.get_yscale() in ["log", "symlog"]:
                    subs = [1.0, 2.0, 3.0, 6.0]  # ticks to show per decade
                    ax.yaxis.set_minor_locator(
                        ticker.LogLocator(subs=subs))  # set the ticks position
                else:
                    minor_locatory = ticker.AutoMinorLocator(5)
                    ax.yaxis.set_minor_locator(minor_locatory)
                    ax.get_yaxis().get_major_formatter().set_useOffset(False)

                minor_locatorx = ticker.AutoMinorLocator(5)
                ax.xaxis.set_minor_locator(minor_locatorx)

            else:
                ax.set_ylabel("")
                for tick in ax.yaxis.get_major_ticks():
                    tick.label1On = False
                    tick.label2On = False

        vmax.sort(key=lambda row: row[0])
        for [v, labels, lines] in reversed(vmax):
            lns.append(lines)
            labs.append(labels)

        if len(lns) < 7:
            size = 10
        else:
            size = 10 - 0.82 * len(lns) / 7
        self.ax.legend(lns, labs, loc=0, prop={'size': size})
    def updateLimit(self, bool_draw=False):
        if not bool_draw:
            self.fig.canvas.restore_region(self.background)

        list_tmax = []
        t0, tmax = self.ax.get_xlim()
        for i, ax in enumerate(self.fig.get_axes()):
            list_min_value = []
            list_max_value = []
            for line in ax.lines:
                if not hasattr(self, "linev"):
                    ax.draw_artist(line)
                if self.isinDict(line):
                    ind = indFinder(t0, line.get_xdata())
                    min_value, max_value, max_time = np.min(line.get_ydata()[ind:]), np.max(line.get_ydata()[ind:]), \
                                                     line.get_xdata()[-1]
                    list_tmax.append(max_time)
                    if ax.get_yscale() == "log":
                        list_min_value.append(10**(floor(log10(min_value))))
                        list_max_value.append(10**(floor(log10(max_value)) +
                                                   1))
                    else:
                        list_min_value.append(min_value)
                        list_max_value.append(max_value)
            min_yaxis, max_yaxis = ax.get_ylim()
            if list_min_value and (not (self.toolbar.isZoomed()
                                        or self.toolbar.isPanned())):
                if np.max(list_max_value) != np.min(list_min_value):
                    if np.min(list_min_value) < min_yaxis:
                        if ax.get_yscale() == "log":
                            ax.set_ylim(np.min(list_min_value), max_yaxis)
                        else:
                            ax.set_ylim(
                                np.min(list_min_value) -
                                (np.max(list_max_value) -
                                 np.min(list_min_value)) * 0.05, max_yaxis)
                        bool_draw = True
                    if np.max(list_max_value) > max_yaxis:
                        if ax.get_yscale() == "log":
                            ax.set_ylim(
                                min_yaxis,
                                np.max(list_max_value) +
                                (np.max(list_max_value) -
                                 np.min(list_min_value)) * 0.05)
                        else:
                            ax.set_ylim(min_yaxis, np.max(list_max_value))
                        bool_draw = True

                else:
                    ax.set_ylim(
                        np.min(list_min_value) * 0.95,
                        np.max(list_max_value) * 1.05)
                    bool_draw = True
        if list_tmax:
            if np.max(list_tmax) > tmax and not self.toolbar.isZoomed():
                samp_time = 0.28 * (np.max(list_tmax) - t0)
                self.ax.set_xlim(t0, np.add(np.max(list_tmax), samp_time))
                bool_draw = True

        if bool_draw:
            self.fig.canvas.draw()

        else:
            self.fig.canvas.blit(self.fig.bbox)

        self.onDrawing = False
    def updateStyle(self):
        lns = []
        labs = []
        vmax = []
        self.ax.set_xlabel('Time')
        for i, ax in enumerate(self.fig.get_axes()):
            if ax.get_lines():
                ax.set_ylabel(self.dictofline[ax.get_lines()[0]].ylabel, color=self.dictofline[ax.get_lines()[0]].color)
                for tick in ax.yaxis.get_major_ticks():
                    if i == 0:
                        tick.label1On = True
                        tick.label2On = False
                        tick.label1.set_color(color=self.dictofline[ax.get_lines()[0]].color)
                        self.ax2.grid(which='major', alpha=0.0)
                        ax.grid(which='major', alpha=0.5, color=self.dictofline[ax.get_lines()[0]].color)
                        ax.grid(which='minor', alpha=0.25, color=self.dictofline[ax.get_lines()[0]].color,
                                linestyle='--')
                    elif i == 1:
                        tick.label1On = False
                        tick.label2On = True
                        tick.label2.set_color(color=self.dictofline[ax.get_lines()[0]].color)
                        ax.grid(which='major', alpha=1.0, color=self.dictofline[ax.get_lines()[0]].color,
                                linestyle='dashdot')
                for lines in ax.get_lines():
                    if self.isinDict(lines):
                        t0, tmax = self.ax.get_xlim()
                        ind = indFinder(tmax, lines.get_xdata())
                        try:
                            new_coord = ax.transData.transform((lines.get_xdata()[ind], lines.get_ydata()[ind]))
                        except TypeError:
                            new_coord = transformCoord2Log((lines.get_xdata()[ind], lines.get_ydata()[ind]), self.ax,
                                                           self.ax2, inv=True)

                        vmax.append([new_coord[1], lines.get_label(), lines])
                        self.setLineStyle(lines)

                if ax.get_yscale() in ["log", "symlog"]:
                    subs = [1.0, 2.0, 3.0, 6.0]  # ticks to show per decade
                    ax.yaxis.set_minor_locator(ticker.LogLocator(subs=subs))  # set the ticks position
                else:
                    minor_locatory = ticker.AutoMinorLocator(5)
                    ax.yaxis.set_minor_locator(minor_locatory)
                    ax.get_yaxis().get_major_formatter().set_useOffset(False)

                minor_locatorx = ticker.AutoMinorLocator(5)
                ax.xaxis.set_minor_locator(minor_locatorx)

            else:
                ax.set_ylabel("")
                for tick in ax.yaxis.get_major_ticks():
                    tick.label1On = False
                    tick.label2On = False

        vmax.sort(key=lambda row: row[0])
        for [v, labels, lines] in reversed(vmax):
            lns.append(lines)
            labs.append(labels)

        if len(lns) < 7:
            size = 10
        else:
            size = 10 - 0.82 * len(lns) / 7
        self.ax.legend(lns, labs, loc=0, prop={'size': size})