예제 #1
0
    def generate_barSet(self):

        self.vmafbs_dict = {}
        self.psnrbs_dict = {}
        self.bitratebs_dict = {}

        self.vmaf_barSeries = QtCharts.QBarSeries()
        self.psnr_barSeries = QtCharts.QBarSeries()
        self.bitrate_barSeries = QtCharts.QBarSeries()

        for obj in self.list_obj:

            try:
                self.vmafbs_dict[obj.filename] = QtCharts.QBarSet(obj.filename)
                self.vmafbs_dict[obj.filename].append([obj.vmaf_avg])
            except:
                pass

            try:
                self.psnrbs_dict[obj.filename] = QtCharts.QBarSet(obj.filename)
                self.psnrbs_dict[obj.filename].append([obj.psnr_avg])
            except:
                pass

            try:
                self.bitratebs_dict[obj.filename] = QtCharts.QBarSet(
                    obj.filename)
                self.bitratebs_dict[obj.filename].append([obj.bitrate_avg])
            except:
                pass
예제 #2
0
    def createBarCharts(self, x, y1, y2):
        barSet1 = QtCharts.QBarSet("Magnitude")
        # c1 = PySide2.QtWidgets.QColorDialog.getColor()
        barSet1.setColor(Qt.white)
        barSet1.append(y1)

        barSet2 = QtCharts.QBarSet("Depths")
        barSet2.setColor(Qt.magenta)
        barSet2.append(y2)

        barSeries1 = QtCharts.QBarSeries()
        barSeries1.append(barSet1)
        barSeries1.append(barSet2)

        barChart1 = QtCharts.QChart()
        barChart1.addSeries(barSeries1)
        barChart1.setTitle("my first bar chart")
        barChart1.setAnimationOptions(QtCharts.QChart.SeriesAnimations)

        categories = x
        barCategoryAxis = QtCharts.QBarCategoryAxis()
        barCategoryAxis.append(categories)
        barChart1.createDefaultAxes()
        barChart1.setAxisX(barCategoryAxis, barSeries1)

        barChart1.legend().setVisible(True)
        barChart1.legend().setAlignment(Qt.AlignTop)

        return barChart1
예제 #3
0
    def plotSavingsBars(self):
        chart = QtCharts.QChart()

        # barSets = []
        maxVal = 0
        minVal = 0
        barSeries = QtCharts.QBarSeries()
        expSet = QtCharts.QBarSet('Ausgaben')
        expSet.append(self.sumData['exp'])
        maxVal = max(maxVal, max(self.sumData['exp']))
        minVal = min(minVal, min(self.sumData['exp']))
        barSeries.append(expSet)

        incSet = QtCharts.QBarSet('Einnahmen')
        incSet.append(self.sumData['inc'])
        maxVal = max(maxVal, max(self.sumData['inc']))
        minVal = min(minVal, min(self.sumData['inc']))
        barSeries.append(incSet)

        savSet = QtCharts.QBarSet('Rücklagen')
        savSet.append(self.sumData['sav'])
        maxVal = max(maxVal, max(self.sumData['sav']))
        minVal = min(minVal, min(self.sumData['sav']))
        barSeries.append(savSet)

        # self.barSets = barSets

        chart.addSeries(barSeries)
        titleFont = QFont("Sans Serif")
        titleFont.setPointSize(16)
        titleFont.setBold(True)

        chart.setTitleFont(titleFont)
        chart.setTitle("Rücklagen")

        axisX = QtCharts.QBarCategoryAxis()
        axisX.append(self.plotDataTags)
        chart.setAxisX(axisX, barSeries)
        # axisX.setRange(self.plotDataTags[0], self.plotDataTags[-1])

        axisY = QtCharts.QValueAxis()
        axisY.setLabelFormat("%i")
        axisY.setTitleText("€")
        if minVal < 0:
            self.setYRange(maxVal, axisY, minVal)
        else:
            self.setYRange(maxVal, axisY)
        # chart.setAxisY(axisY, lineSeries)
        chart.setAxisY(axisY, barSeries)
        # axisY.setRange(0, 20)

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignRight)

        self.setChart(chart)
        self.setRenderHint(QPainter.Antialiasing)
        # draw the plot from scratch (if that makes a difference)
        print('Savings bar plot drawn')
예제 #4
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.set0 = QtCharts.QBarSet("Jane")
        self.set1 = QtCharts.QBarSet("John")
        self.set2 = QtCharts.QBarSet("Axel")
        self.set3 = QtCharts.QBarSet("Mary")
        self.set4 = QtCharts.QBarSet("Sam")

        self.set0.append([1, 2, 3, 4, 5, 6])
        self.set1.append([5, 0, 0, 4, 0, 7])
        self.set2.append([3, 5, 8, 13, 8, 5])
        self.set3.append([5, 6, 7, 3, 4, 5])
        self.set4.append([9, 7, 5, 3, 1, 2])

        self.barSeries = QtCharts.QBarSeries()
        self.barSeries.append(self.set0)
        self.barSeries.append(self.set1)
        self.barSeries.append(self.set2)
        self.barSeries.append(self.set3)
        self.barSeries.append(self.set4)

        self.lineSeries = QtCharts.QLineSeries()
        self.lineSeries.setName("trend")
        self.lineSeries.append(QPoint(0, 4))
        self.lineSeries.append(QPoint(1, 15))
        self.lineSeries.append(QPoint(2, 20))
        self.lineSeries.append(QPoint(3, 4))
        self.lineSeries.append(QPoint(4, 12))
        self.lineSeries.append(QPoint(5, 17))

        self.chart = QtCharts.QChart()
        self.chart.addSeries(self.barSeries)
        self.chart.addSeries(self.lineSeries)
        self.chart.setTitle("Line and barchart example")

        self.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
        self.axisX = QtCharts.QBarCategoryAxis()
        self.axisX.append(self.categories)
        self.chart.setAxisX(self.axisX, self.lineSeries)
        self.chart.setAxisX(self.axisX, self.barSeries)
        self.axisX.setRange("Jan", "Jun")

        self.axisY = QtCharts.QValueAxis()
        self.chart.setAxisY(self.axisY, self.lineSeries)
        self.chart.setAxisY(self.axisY, self.barSeries)
        self.axisY.setRange(0, 20)

        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignBottom)

        self.chartView = QtCharts.QChartView(self.chart)
        self.chartView.setRenderHint(QPainter.Antialiasing)

        self.setCentralWidget(self.chartView)
예제 #5
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        bar_set = QtCharts.QBarSet("ME")
        bar_set.setColor(QColor(231, 119, 32))
        self.task_list = None
        self.setFont("Roboto Light")

        self.max_bound: datetime = datetime.datetime.now()

        self.setFixedSize(651, 421)
        self.interval = 7

        self.series = QtCharts.QBarSeries()
        self.chart = QtCharts.QChart()
        self.chart.addSeries(self.series)
        self.chart.setFont("Roboto Light")
        self.chart.setTitle("Task Done")
        self.chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)

        self.axisX = QtCharts.QBarCategoryAxis()
        self.axisY = QtCharts.QValueAxis()

        self.chart.setAxisY(self.axisY, self.series)
        self.chart.setAxisX(self.axisX, self.series)
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(Qt.AlignBottom)

        self.chartView = QtCharts.QChartView(self.chart)
        self.chartView.setRenderHint(QPainter.Antialiasing)

        self.main_layout = QVBoxLayout(self)
        self.main_layout.addWidget(self.chartView)
        self.setLayout(self.main_layout)
예제 #6
0
    def _set_returns_chart(self,
                           asset_universe: List[str],
                           implied_returns: pd.Series) -> None:

        implied_returns = implied_returns.reindex(asset_universe)
        bar_series = QtCharts.QBarSeries()
        bar_set = QtCharts.QBarSet("Returns")
        bar_set.append(implied_returns.mul(100).values.tolist())
        bar_series.append(bar_set)

        # configure basic chart
        chart = QtCharts.QChart()
        chart.setTitle("Market Implied Expected Returns")
        title_font = QtGui.QFont()
        title_font.setBold(True)
        chart.setFont(title_font)
        chart.addSeries(bar_series)

        # configure the x axis
        axis_x = QtCharts.QBarCategoryAxis()
        axis_x.append([s.replace(" ", "<br>") for s in asset_universe])
        chart.createDefaultAxes()
        chart.setAxisX(axis_x)

        # configure the y axis
        y_min = implied_returns.min() * 100
        y_max = implied_returns.max() * 100
        axis_y = QtCharts.QValueAxis()
        self._set_y_axis_limits(y_max, y_min, axis_y, 2)
        axis_y.setLabelFormat("%.0f")
        axis_y.setTitleText("Expected Return (%pa)")
        chart.setAxisY(axis_y)
        bar_series.attachAxis(axis_y)

        self._returns_chart_view.setChart(chart)
예제 #7
0
    def __init__(self):
        QMainWindow.__init__(self)
        low = QtCharts.QBarSet("Min")
        high = QtCharts.QBarSet("Max")
        low.append([
            -52, -50, -45.3, -37.0, -25.6, -8.0, -6.0, -11.8, -19.7, -32.8,
            -43.0, -48.0
        ])
        high.append([
            11.9, 12.8, 18.5, 26.5, 32.0, 34.8, 38.2, 34.8, 29.8, 20.4, 15.1,
            11.8
        ])

        series = QtCharts.QStackedBarSeries()
        series.append(low)
        series.append(high)

        chart = QtCharts.QChart()
        chart.addSeries(series)
        chart.setTitle("Temperature records in celcius")
        chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)

        categories = [
            "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
            "Oct", "Nov", "Dec"
        ]
        axisX = QtCharts.QBarCategoryAxis()
        axisX.append(categories)
        axisX.setTitleText("Month")
        chart.addAxis(axisX, Qt.AlignBottom)
        axisY = QtCharts.QValueAxis()
        axisY.setRange(-52, 52)
        axisY.setTitleText("Temperature [&deg;C]")
        chart.addAxis(axisY, Qt.AlignLeft)
        series.attachAxis(axisX)
        series.attachAxis(axisY)

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)

        chart_view = QtCharts.QChartView(chart)
        chart_view.setRenderHint(QPainter.Antialiasing)

        self.setCentralWidget(chart_view)
예제 #8
0
 def setBarChartData(self, data: List[int]):
     barSet = QtCharts.QBarSet("Days")
     barSet.append(data)
     series = QtCharts.QBarSeries()
     series.append(barSet)
     chartBar = QtCharts.QChart()
     chartBar.addSeries(series)
     chartBar.setTitle("Reviews by days")
     chartBar.setAnimationOptions(QtCharts.QChart.SeriesAnimations)
     self.chartBarView.setChart(chartBar)
예제 #9
0
    def creador_barset(self, titulo, datos, color=None):

        barra = QtCharts.QBarSet(titulo)  # titulo
        barra.append(datos)  # datos
        if not (color is None):
            barra.setColor(color)  # color leyenda
            barra.setLabelColor("white")  # color valor
            barra.setLabelFont(self.font_size(13))  # tamaño letra

        return barra
예제 #10
0
 def plot_data(self):
     presence = QtCharts.QBarSet('現在')
     goal = QtCharts.QBarSet('目標')
     presence.append([self.total_calorie/self.goal_calorie,self.total_protein/self.goal_protein,\
         self.total_fat/self.goal_fat,self.total_carbon/self.goal_carbon])
     goal.append([1,1,1,1])
     series = QtCharts.QBarSeries()
     series.append(presence); series.append(goal)
     chart = QtCharts.QChart()
     chart.addSeries(series)
     chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)
     labels = ['カロリー','たんぱく質','脂質','炭水化物']
     axisX = QtCharts.QBarCategoryAxis()
     axisX.append(labels)
     chart.addAxis(axisX,Qt.AlignBottom)
     chart.legend().setVisible(True)
     chart.legend().setFont(QtGui.QFont('Arial',10,QtGui.QFont.Bold))
     chart.setTheme(QtCharts.QChart.ChartThemeHighContrast)
     self.chartview.setChart(chart)
    def __init__(self, dayIndex, timeIndex, areaIndex):
        super(userDataVisual, self).__init__()
        self.setupUi(self)
        self.bg_pixmap = QPixmap(u":/bg.jpg")
        self.org_bg_pixmap = QPixmap(u":/bg.jpg")

        self.__dayIndex = dayIndex
        self.__timeIndex = timeIndex
        self.__areaIndex = areaIndex

        start_time, end_time = self.getTimeRange()
        month_time, day_time = self.getDay()
        analyser = DataAnalysis(start_time, end_time, month_time, day_time,
                                self.__areaIndex)

        self.average_temperature.setText("平均温度:{}".format(
            round(analyser.average_temperature, 2)))
        self.people_count.setText("总人数:{}".format(analyser.people_count))
        self.area_risk.setText(
            "该地区风险:{}".format("低" if analyser.area_risk_level == 0 else "高"))

        categories_count = analyser.get_people_count_by_temperature_range(
            35, 38.5, 0.5)
        self.set0 = QtCharts.QBarSet("temp-count")
        self.set0.append(categories_count)
        self.barSeries = QtCharts.QBarSeries()
        self.barSeries.append(self.set0)

        self.chart = QtCharts.QChart()
        self.chart.addSeries(self.barSeries)
        self.chart.setTitle("区域时段统计图")

        self.categories = ["35以下"]
        self.categories.extend(
            [str(i * 0.5 + 35) for i in range(len(categories_count) - 2)])
        self.categories.extend(["38.5以上"])
        self.axisX = QtCharts.QBarCategoryAxis()
        self.axisX.append(self.categories)
        self.chart.setAxisX(self.axisX, self.barSeries)
        self.axisX.setRange("35以下", "38.5以上")

        self.axisY = QtCharts.QValueAxis()
        self.chart.setAxisY(self.axisY, self.barSeries)
        self.axisY.setRange(min(categories_count), max(categories_count))

        self.chart.axisY().setTitleText("人数")
        self.chart.axisX().setTitleText("体温")
        self.chart.legend().setVisible(False)
        self.chart.legend().setAlignment(Qt.AlignBottom)

        self.chartView = QtCharts.QChartView(self.chart, self.centralwidget)
        self.chartView.setRenderHint(QPainter.Antialiasing)
        self.chartView.setGeometry(QRect(50, 50, 600, 450))
예제 #12
0
    def __init__(self):
        QMainWindow.__init__(self)

        set0 = QtCharts.QBarSet("Jane")
        set1 = QtCharts.QBarSet("John")
        set2 = QtCharts.QBarSet("Axel")
        set3 = QtCharts.QBarSet("Mary")
        set4 = QtCharts.QBarSet("Samantha")

        set0.append([1, 2, 3, 4, 5, 6])
        set1.append([5, 0, 0, 4, 0, 7])
        set2.append([3, 5, 8, 13, 8, 5])
        set3.append([5, 6, 7, 3, 4, 5])
        set4.append([9, 7, 5, 3, 1, 2])

        series = QtCharts.QPercentBarSeries()
        series.append(set0)
        series.append(set1)
        series.append(set2)
        series.append(set3)
        series.append(set4)

        chart = QtCharts.QChart()
        chart.addSeries(series)
        chart.setTitle("Simple percentbarchart example")
        chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)

        categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
        axis = QtCharts.QBarCategoryAxis()
        axis.append(categories)
        chart.createDefaultAxes()
        chart.setAxisX(axis, series)

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)

        chart_view = QtCharts.QChartView(chart)
        chart_view.setRenderHint(QPainter.Antialiasing)

        self.setCentralWidget(chart_view)
예제 #13
0
파일: charts.py 프로젝트: djdt/nanopart
    def __init__(self, parent: QtWidgets.QGraphicsItem = None):
        super().__init__(parent)
        self.setMinimumSize(640, 320)

        self._xaxis = QtCharts.QValueAxis()
        self._xaxis.setVisible(False)

        self.xaxis = NiceValueAxis()
        self.xaxis.setTitleText("Size (nm)")
        self.xaxis.setGridLineVisible(False)

        self.yaxis = QtCharts.QValueAxis()
        self.yaxis.setGridLineVisible(False)
        self.yaxis.setTitleText("Count")
        self.yaxis.setLabelFormat("%d")

        self.addAxis(self._xaxis, QtCore.Qt.AlignBottom)
        self.addAxis(self.xaxis, QtCore.Qt.AlignBottom)
        self.addAxis(self.yaxis, QtCore.Qt.AlignLeft)

        self.series = QtCharts.QBarSeries()
        self.series.setBarWidth(0.9)
        self.addSeries(self.series)
        self.series.attachAxis(self._xaxis)
        self.series.attachAxis(self.yaxis)

        self.set = QtCharts.QBarSet("sizes")
        self.set.setColor(QtCore.Qt.black)
        self.set.hovered.connect(self.barHovered)
        self.series.append(self.set)

        self.fit = QtCharts.QSplineSeries()
        self.fit.setPen(QtGui.QPen(QtGui.QColor(255, 172, 0), 2.0))
        self.addSeries(self.fit)
        self.fit.attachAxis(self.xaxis)
        self.fit.attachAxis(self.yaxis)

        self.label_fit = QtWidgets.QGraphicsTextItem(self)
        self.label_fit.setFont(QtGui.QFont("sans", 12, italic=False))
        self.label_fit.setZValue(99)
        self.label_fit.setDefaultTextColor(QtGui.QColor(255, 172, 0))
        self.xaxis.rangeChanged.connect(self.updateFitLabelPos)

        self.label_hovered = QtWidgets.QGraphicsTextItem(self)
        self.plotAreaChanged.connect(self.updateHoveredLabelPos)

        self.vlines: List[QtCharts.QLineSeries] = []

        # Clean legend
        self.legend().setMarkerShape(QtCharts.QLegend.MarkerShapeFromSeries)
        self.legend().markers(self.series)[0].setVisible(False)
예제 #14
0
    def __init__(self):
        super(Teacher_OP, self).__init__()
        self.setupUi(self)
        self.time = 0
        self.num = 0  # 记录上张表的标签数量

        self.get_time_timer = QTimer(self)

        self.get_table_list_thread = Table_List_Get(self)

        self.count_timer = QTimer(self)

        self.clear_msg_timer = QTimer(self)

        self.list_model = QStringListModel()
        self.table_list.setModel(self.list_model)

        self.get_table_data_thread = Table_Data_Get(self)

        self.start_sign_thread = Start_Sign_IN(self)

        self.stop_sign_thread = Stop_Sign_IN(self)

        self.get_time_thread = Get_Time(self)

        self.delete_table_thread = Delete_Option(self)

        self.train_model_thread = Train_Model(self)

        self.creat_excel_thread = Creat_Excel(self)

        # chart
        self.series = QtCharts.QBarSeries(self)
        self.target_bar = QtCharts.QBarSet('学生数量')
        self.series.append(self.target_bar)

        self.axis_x = QtCharts.QBarCategoryAxis()
        self.axis_x.setLabelsColor(QColor(255, 0, 0))

        self.axis_y = QtCharts.QValueAxis()
        # self.axis_y.setTitleText('人数')

        self.chart = QtCharts.QChart()
        self.chart.addSeries(self.series)
        self.chart.setAxisX(self.axis_x, self.series)
        self.chart.setAxisY(self.axis_y, self.series)

        self.qcv = QtCharts.QChartView(self.chart)

        self.init_connect()
        self.set_start_dis_and_set_stop_en(False)
예제 #15
0
    def plot_data(self):
        # Get table information
        series = QtCharts.QBarSeries()
        for i in range(self.table.rowCount()):
            text = self.table.item(i, 0).text()
            number = float(self.table.item(i, 1).text())

            bar_set = QtCharts.QBarSet(text)
            bar_set.append(number)

            series.append(bar_set)

        chart = QtCharts.QChart()
        chart.addSeries(series)
        chart.legend().setAlignment(Qt.AlignLeft)
        self.chart_view.setChart(chart)
예제 #16
0
    def setData(self, data: Dict[Any, int], asRanges: bool = False):
        self.clearChart()
        if not data:
            return
        barSet = QtCharts.QBarSet('Frequency')
        frequencies = [f for f in data.values()]
        self.currentBinN = len(frequencies)
        barSet.append(frequencies)
        series = QtCharts.QBarSeries()
        series.append(barSet)
        chart = QtCharts.QChart()
        chart.addSeries(series)
        chart.setTitle('Value frequency ({} bins)'.format(self.currentBinN))
        chart.setAnimationOptions(QtCharts.QChart.SeriesAnimations)

        labels = ['{:.2f}'.format(k) if isinstance(k, float) else str(k) for k in data.keys()]
        if asRanges:
            if isFloat(labels[0]):
                # Assume labels are float
                if len(labels) > 1:
                    # If there is one or less labels stop
                    lastEnd = float(labels[-1]) + (float(labels[1]) - float(labels[0]))
                    labels.append('{:.2f}'.format(lastEnd))
            axisX = QtCharts.QCategoryAxis()
            for i in range(len(labels) - 1):
                axisX.append(labels[i + 1], (i + 1) * 2 * series.barWidth())
            axisX.setStartValue(0)
            axisX.setLabelsPosition(QtCharts.QCategoryAxis.AxisLabelsPositionCenter)
        else:
            axisX = QtCharts.QBarCategoryAxis()
            axisX.append(labels)
        # Set font
        font: QFont = axisX.labelsFont()
        font.setPointSize(11)
        axisX.setLabelsFont(font)
        chart.addAxis(axisX, Qt.AlignBottom)
        series.attachAxis(axisX)

        axisY = QtCharts.QValueAxis()
        axisY.setRange(0, max(frequencies) + 1)
        axisY.setLabelFormat('%d')
        chart.addAxis(axisY, Qt.AlignLeft)
        series.attachAxis(axisY)
        chart.legend().setVisible(False)

        self.chart = chart
        self.chartView.setChart(self.chart)
예제 #17
0
    def _set_weights_chart(self,
                           asset_universe: List[str],
                           *args: pd.Series) -> None:

        bar_series = QtCharts.QBarSeries()
        y_min = 0
        y_max = 0

        for weights in args:

            weights = weights.reindex(asset_universe)
            y_min = min(weights.min() * 100, y_min)
            y_max = max(weights.max() * 100, y_max)

            bar_set = QtCharts.QBarSet(str(weights.name))
            bar_set.append(weights.mul(100).values.tolist())
            bar_series.append(bar_set)

        # configure basic chart
        chart = QtCharts.QChart()
        chart.setTitle("Black-Litterman Asset Allocation")
        title_font = QtGui.QFont()
        title_font.setBold(True)
        chart.setFont(title_font)
        chart.addSeries(bar_series)

        # configure the x axis
        axis_x = QtCharts.QBarCategoryAxis()
        axis_x.append([s.replace(" ", "<br>") for s in asset_universe])
        chart.createDefaultAxes()
        chart.setAxisX(axis_x)

        # configure the y axis
        axis_y = QtCharts.QValueAxis()
        self._set_y_axis_limits(y_max, y_min, axis_y)
        axis_y.setLabelFormat("%.0f")
        axis_y.setTitleText("Suggested Allocation (%)")
        chart.setAxisY(axis_y)
        bar_series.attachAxis(axis_y)

        # configure chart legend
        chart.legend().setVisible(True)
        chart.legend().setAlignment(QtCore.Qt.AlignBottom)

        self._weights_chart_view.setChart(chart)
    def drawBar(self):
        axisX = QtCharts.QValueAxis()
        axisX.setRange(TIMEZONE0, TIMEZONE6)
        axisX.setTickCount(31)
        axisX.setLabelFormat("%i")
        axisX.setTitleText("→ Time (sec)")

        font = QtGui.QFont()
        font.setPointSize(12)
        # font.setFamily("Gothic")

        self.fases = dict(
            (f"{x}", QtCharts.QBarSet(f"{x}") << 0) for x in range(6))

        series = QtCharts.QHorizontalStackedBarSeries()
        for x, v in self.fases.items():
            series.append(v)

        self.chart = QtCharts.QChart()
        self.chart.setTheme(QtCharts.QChart.ChartThemeHighContrast)
        self.chart.addSeries(series)
        self.chart.setAnimationOptions(QtCharts.QChart.NoAnimation)
        self.chart.legend().setVisible(True)
        self.chart.legend().setAlignment(QtCore.Qt.AlignBottom)
        self.chart.legend().setFont(font)
        self.chart.setAxisX(axisX)

        series.attachAxis(axisX)

        self.fases["0"].setLabel("Preparation")
        self.fases["0"].setColor(COLOR_PREPARE)
        self.fases["1"].setLabel("Measurement 1")
        self.fases["1"].setColor(COLOR_MEASURE)
        self.fases["2"].setLabel("Rest Period 1")
        self.fases["2"].setColor(COLOR_REST)
        self.fases["3"].setLabel("Measurement 2")
        self.fases["3"].setColor(COLOR_MEASURE)
        self.fases["4"].setLabel("Rest Period 2")
        self.fases["4"].setColor(COLOR_REST)
        self.fases["5"].setLabel("Measurement 3")
        self.fases["5"].setColor(COLOR_MEASURE)

        self.setChart(self.chart)
예제 #19
0
    def createBarChart(self):
        chart = QtCharts.QChart()
        chart.setTitle("Bar chart")

        series = QtCharts.QStackedBarSeries(chart)
        for i in range(len(self.data_table)):
            barset = QtCharts.QBarSet("Bar set {}".format(i))
            for data in self.data_table[i]:
                barset.append(data[0].y())
            series.append(barset)

        chart.addSeries(series)

        chart.createDefaultAxes()
        chart.axisY().setRange(0, self.value_max * 2)
        # Add space to label to add space between labels and axis
        chart.axisY().setLabelFormat("%.1f  ")

        return chart
예제 #20
0
파일: histogram.py 프로젝트: djdt/pewpew
    def setHistogram(
        self,
        data: np.ndarray,
        bins: Union[int, str] = "auto",
        min_bins: int = 16,
        max_bins: int = 128,
    ) -> None:
        """Draw 'data' as a histogram.

        Args:
            data: hist data
            bins: passed to np.histogram_bin_edges
            min_bins: minimum number of bins
            max_bins: maximum number of bins
        """
        vmin, vmax = np.percentile(data, 5), np.percentile(data, 95)

        barset = QtCharts.QBarSet("histogram")
        barset.setColor(sequential[1])
        barset.setLabelColor(light_theme["text"])

        bin_edges = np.histogram_bin_edges(data, bins=bins, range=(vmin, vmax))
        if bin_edges.size > max_bins:
            bin_edges = np.histogram_bin_edges(data,
                                               bins=max_bins,
                                               range=(vmin, vmax))
        elif bin_edges.size < min_bins:
            bin_edges = np.histogram_bin_edges(data,
                                               bins=min_bins,
                                               range=(vmin, vmax))

        hist, edges = np.histogram(data, bins=bin_edges)
        barset.append(list(hist))

        self.series.clear()
        self.series.append(barset)

        self._xaxis.setRange(-0.5, hist.size - 0.5)
        self.xaxis.setRange(edges[0], edges[-1])
        self.yaxis.setRange(0, np.amax(hist))
        self.yaxis.applyNiceNumbers()
예제 #21
0
    def update_chart(self, task_list: TaskList, current_date=None):
        self.axisX.clear()
        self.series.clear()
        self.task_list = task_list

        result = TaskAnalyser.countDoneTaskFromInteval(task_list,
                                                       self.max_bound,
                                                       self.interval)

        self.axisX.append([
            self.date_to_string(self.max_bound - datetime.timedelta(days=i))
            for i in range(self.interval - 1, -1, -1)
        ])

        self.axisY.setRange(min(result), max(result) + max(result) * 0.3)

        bar_set = QtCharts.QBarSet("Done tasks in each day")
        bar_set.setColor(QColor(231, 119, 32))
        bar_set.append(result)
        self.series.append(bar_set)
        self.update()
예제 #22
0
    def Create_Bar_Graph(self, data_df, name):

        self.graph_4 = QtCharts.QChartView()
        self.graph_4.series = QtCharts.QBarSeries()
        """
        self.graph_4 = QtCharts.QChartView(self.frame_4)
        self.graph_4.series = QtCharts.QBarSeries(self.frame_4)
        """
        for column in data_df.columns:
            bar_set = QtCharts.QBarSet(column)
            bar_set.append(list(data_df[column].values))
            self.graph_4.series.append(bar_set)
        self.graph_4.chart().setTitle("Device Summary")
        self.graph_4.chart().addSeries(self.graph_4.series)

        #self.graph_4.setGeometry(0, 0, self.frame_4.width(), self.frame_4.height())
        axis = QtCharts.QBarCategoryAxis()
        axis.append(["Pixels"])
        self.graph_4.chart().createDefaultAxes()
        self.graph_4.chart().addAxis(axis, QtCore.Qt.AlignBottom)
        self.frame_layout.addWidget(self.graph_4)
        self.Resize()
예제 #23
0
    def add_bar_series(self, res_dict):
        self.barset = QtCharts.QBarSet('Watson')
        cats = []
        for item in res_dict:
            self.barset.append(res_dict[item])
            cats.append(item)

        self.series = QtCharts.QBarSeries()
        self.series.append(self.barset)
        self.chart.addSeries(self.series)

        # Setting X-axis
        self.axis_x = QtCharts.QBarCategoryAxis()
        cat = ('sadness', 'joy', 'fear', 'disgust', 'anger')
        self.axis_x.append(cat)
        self.chart.addAxis(self.axis_x, Qt.AlignBottom)
        self.series.attachAxis(self.axis_x)

        # Setting Y-axis
        self.axis_y = QtCharts.QValueAxis()
        # self.axis_y.setTitleText("Percentage")
        self.chart.addAxis(self.axis_y, Qt.AlignLeft)
        self.series.attachAxis(self.axis_y)
예제 #24
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setWindowTitle('MNIST Image Classification Test')

        self.canvas = Canvas()
        size_policy = QtWidgets.QSizePolicy(
            QtWidgets.QSizePolicy.MinimumExpanding,
            QtWidgets.QSizePolicy.MinimumExpanding)
        size_policy.setHeightForWidth(True)
        self.canvas.setSizePolicy(size_policy)

        self.probabilities = QtCharts.QBarSet('Probability')
        self.probabilities.append([0.1 for _ in range(10)])
        series = QtCharts.QBarSeries()
        series.append(self.probabilities)
        chart = QtCharts.QChart()
        chart.addSeries(series)
        chart_view = QtCharts.QChartView(chart)
        chart_view.setSizePolicy(size_policy)

        x_axis = QtCharts.QBarCategoryAxis()
        x_axis.setCategories([str(i) for i in range(10)])
        chart.addAxis(x_axis, QtCore.Qt.AlignBottom)
        series.attachAxis(x_axis)

        y_axis = QtCharts.QValueAxis()
        y_axis.setRange(0.0, 1.0)
        y_axis.setTickCount(11)
        chart.addAxis(y_axis, QtCore.Qt.AlignLeft)
        series.attachAxis(y_axis)

        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(self.canvas)
        layout.addWidget(chart_view)

        self.setLayout(layout)
        self.show()
예제 #25
0
def copyChart(chart: QtCharts.QChart) -> QtCharts.QChart:
    """ Return a copy of the chart """
    newChart = QtCharts.QChart()
    # Copy axes
    axes = chart.axes()
    for axis in axes:
        newChart.addAxis(copyAxis(newChart, axis), axis.alignment())
    # Copy series
    allSeries: List[QtCharts.QAbstractSeries] = chart.series()
    for s in allSeries:
        # Create new series with same points, dependent on actual type
        s_copy: QtCharts.QAbstractSeries
        if isinstance(s, QtCharts.QScatterSeries):
            s_copy = QtCharts.QScatterSeries()
            s_copy.append(s.points())
        elif isinstance(s, QtCharts.QLineSeries):
            s_copy = QtCharts.QLineSeries()
            s_copy.append(s.points())
        elif isinstance(s, QtCharts.QAbstractBarSeries):
            # Note: this is not used
            s_copy = QtCharts.QBarSeries()
            for bar in s.barSets():
                bar_copy = QtCharts.QBarSet(bar.label())
                s_copy.append(bar_copy)
        else:
            raise NotImplementedError('Cannot copy series of type {}'.format(
                type(s)))
        s_copy.setName(s.name())
        # Add series to chart
        newChart.addSeries(s_copy)
        # Add axis to series
        s_copy.attachAxis(newChart.axisX())
        s_copy.attachAxis(newChart.axisY())
    if chart.title():
        newChart.setTitle(chart.title())
    return newChart
예제 #26
0
 def add_barset(self):
     series_count = self.series.count()
     bar_set = QtCharts.QBarSet("set {}".format(series_count))
     delta = series_count * 0.1
     bar_set.append([1 + delta, 2 + delta, 3 + delta, 4 + delta])
     self.series.append(bar_set)
예제 #27
0
    def plotAllExpenseBars(self, legendPlot=None):
        chart = QtCharts.QChart()

        barSets = []
        barSeries = QtCharts.QBarSeries()
        maxVal = 0
        if legendPlot is None:
            catList = ['Alle']
            for cat in list(self.plotData.keys()):
                if cat == "Einnahmen" or cat == "Zählerstände":
                    continue
                barSet = QtCharts.QBarSet(cat)
                barSet.append(self.plotData[cat])
                barSets.append(barSet)
                barSeries.append(barSet)
                catList.append(cat)
                maxVal = max(maxVal, max(self.plotData[cat]))
            self.barSets = barSets
            self.catList = catList
        else:
            barSet = QtCharts.QBarSet(legendPlot)
            barSet.append(self.plotData[legendPlot])
            barSets.append(barSet)
            barSeries.append(barSet)
            maxVal = max(self.plotData[legendPlot])

        chart.addSeries(barSeries)

        titleFont = QFont("Sans Serif")
        titleFont.setPointSize(16)
        titleFont.setBold(True)
        chart.setTitleFont(titleFont)
        if legendPlot is None:
            chart.setTitle("Ausgaben")
        else:
            chart.setTitle("Ausgaben: " + legendPlot)

        axisX = QtCharts.QBarCategoryAxis()
        axisX.append(self.plotDataTags)
        chart.setAxisX(axisX, barSeries)
        # axisX.setRange(self.plotDataTags[0], self.plotDataTags[-1])

        axisY = QtCharts.QValueAxis()
        axisY.setLabelFormat("%i")
        axisY.setTitleText("€")
        self.setYRange(maxVal, axisY)
        # chart.setAxisY(axisY, lineSeries)
        chart.setAxisY(axisY, barSeries)
        # axisY.setRange(0, 20)

        if legendPlot is None:
            chart.legend().setVisible(True)
            chart.legend().setAlignment(Qt.AlignRight)
        else:
            chart.legend().setVisible(False)

        self.setChart(chart)
        self.setRenderHint(QPainter.Antialiasing)
        if legendPlot is None:
            self.sgn_updateLegendSelection.emit(self.catList)
        # draw the plot from scratch (if that makes a difference)
        print('Expense bar plot drawn')
예제 #28
0
    def createChart(self, title, days, type, db):

        with open('config.json', 'r') as f:
            config = json.load(f)
            names = config['SEARCH']

        if (type == "lines"):
            datesLookUp = self.DateSeriesMongoDB(
                self.calcultateFirstDate(days))
            datesAvailable = self.datesWithData(datesLookUp, db, title)

            series = []

            for name in names:
                newSeries = QtCharts.QLineSeries()
                newSeries.setName(name)
                #series.append(self.fillLineSeries(newSeries, datesLookUp, db, title))
                series.append(
                    self.fillLineSeries(newSeries, datesAvailable, db, title,
                                        name))

            chart = QtCharts.QChart()
            for serie in series:
                chart.addSeries(serie)

            chart.setTitle(title)

            #datesAxis = self.calculateDateSeries(self.calcultateFirstDate(days))
            print(datesAvailable)
            datesAxis = [dt.strftime("%m-%d") for dt in datesAvailable]
            print(datesAxis)
            chart.createDefaultAxes()
            axisX = QtCharts.QBarCategoryAxis()
            axisY = QtCharts.QValueAxis()
            axisX.append(datesAxis)
            axisX.setRange(datesAxis[0], datesAxis[len(datesAxis) - 1])

            for serie in series:
                chart.setAxisX(axisX, serie)
                chart.setAxisY(axisY, serie)

            chart.legend().setVisible(True)
            chart.legend().setAlignment(Qt.AlignBottom)
            chartView = QtCharts.QChartView(chart)
            chartView.setMinimumSize(700, 500)
            chartView.setRenderHint(QPainter.Antialiasing)

            return chartView

        elif (type == "bars"):

            datesLookUp = self.DateSeriesMongoDB(
                self.calcultateFirstDate(days))
            datesAvailable = self.datesWithData(datesLookUp, db, title)

            series = []

            for name in names:
                newSeries = QtCharts.QBarSet(name)
                #series.append(self.fillBarSeries(newSeries, datesLookUp, db, title))
                series.append(
                    self.fillBarSeries(newSeries, datesAvailable, db, title,
                                       name))

            chart = QtCharts.QChart()
            barSeries = QtCharts.QBarSeries()
            for serie in series:
                barSeries.append(serie)

            chart.setTitle(title)
            chart.addSeries(barSeries)

            #datesAxis = self.calculateDateSeries(self.calcultateFirstDate(days))
            datesAxis = [dt.strftime("%m-%d") for dt in datesAvailable]
            chart.createDefaultAxes()

            axisX = QtCharts.QBarCategoryAxis()
            axisX.append(datesAxis)
            chart.setAxisX(axisX, barSeries)
            axisX.setRange(datesAxis[0], datesAxis[len(datesAxis) - 1])

            axisY = QtCharts.QValueAxis()

            chart.legend().setVisible(True)
            chart.legend().setAlignment(Qt.AlignBottom)
            chartView = QtCharts.QChartView(chart)
            chartView.setMinimumSize(700, 500)
            chartView.setRenderHint(QPainter.Antialiasing)

            return chartView

        elif (type == "percentage"):

            datesLookUp = self.DateSeriesMongoDB(
                self.calcultateFirstDate(days))
            datesAvailable = self.datesWithData(datesLookUp, db, title)
            #datesAxis = self.calculateDateSeries(self.calcultateFirstDate(days))
            datesAxis = [dt.strftime("%m-%d") for dt in datesAvailable]

            series = []

            for name in names:
                newSeries = QtCharts.QBarSet(name)
                #series.append(self.fillBarSeries(newSeries, datesLookUp, db, title))
                series.append(
                    self.fillBarSeries(newSeries, datesAvailable, db, title,
                                       name))

            if (len(names) == 1):
                filler = QtCharts.QBarSet("")
                filler.append([100 for item in range(0, len(datesAxis))])
                series.append(filler)

            chart = QtCharts.QChart()
            percentBarSeries = QtCharts.QPercentBarSeries()
            for serie in series:
                percentBarSeries.append(serie)

            chart.setTitle(title)
            chart.addSeries(percentBarSeries)

            chart.createDefaultAxes()

            axisX = QtCharts.QBarCategoryAxis()
            axisX.append(datesAxis)
            chart.setAxisX(axisX, percentBarSeries)
            axisX.setRange(datesAxis[0], datesAxis[len(datesAxis) - 1])

            axisY = QtCharts.QValueAxis()

            chart.legend().setVisible(True)
            chart.legend().setAlignment(Qt.AlignBottom)
            chartView = QtCharts.QChartView(chart)
            chartView.setMinimumSize(700, 500)
            chartView.setRenderHint(QPainter.Antialiasing)

            return chartView
        elif (type == "schedule"):

            datesLookUp = self.DateSeriesMongoDB(
                self.calcultateFirstDate(days))
            datesAvailable = self.datesWithData(datesLookUp, db, title)
            series = []

            for name in names:
                newSeries = QtCharts.QBarSet(name)
                #series.append(self.fillScheduleSeries(newSeries, datesLookUp, db, title))
                series.append(
                    self.fillScheduleSeries(newSeries, datesAvailable, db,
                                            title, name))

            chart = QtCharts.QChart()
            barSeries = QtCharts.QBarSeries()
            for serie in series:
                barSeries.append(serie)

            chart.setTitle(title)
            #datesAxis = self.scheduleAxis(newSeries, datesLookUp, db, title)
            datesAxis = self.scheduleAxis(newSeries, datesAvailable, db, title)
            chart.addSeries(barSeries)

            chart.createDefaultAxes()

            axisX = QtCharts.QBarCategoryAxis()
            axisX.append(datesAxis)
            chart.setAxisX(axisX, barSeries)
            axisX.setRange(datesAxis[0], datesAxis[len(datesAxis) - 1])

            axisY = QtCharts.QValueAxis()

            chart.legend().setVisible(True)
            chart.legend().setAlignment(Qt.AlignBottom)
            chartView = QtCharts.QChartView(chart)
            chartView.setMinimumSize(700, 500)
            #chartView.setMaximumSize(1000,500)
            chartView.setRenderHint(QPainter.Antialiasing)

            return chartView
        else:
            raise "Wrong chart type"