Created
July 18, 2018 18:03
-
-
Save eyllanesc/2eb3fbf5602cc5e37d2c68ebbaed451b to your computer and use it in GitHub Desktop.
proof concept
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from random import randint | |
from PyQt5 import QtCore, QtGui, QtWidgets, QtChart | |
class Widget(QtWidgets.QMainWindow): | |
def __init__(self, parent=None): | |
super(Widget, self).__init__(parent) | |
series = QtChart.QLineSeries() | |
for i in range(10): | |
series << QtCore.QPointF(i, randint(3, 5)**i) | |
chart = QtChart.QChart() | |
chart.addSeries(series) | |
axisX = QtChart.QValueAxis() | |
axisX.setTitleText("Data point") | |
axisX.setLabelFormat("%i") | |
axisX.setTickCount(series.count()) | |
chart.addAxis(axisX, QtCore.Qt.AlignBottom) | |
series.attachAxis(axisX) | |
axisY = QtChart.QLogValueAxis() | |
axisY.setTitleText("Values") | |
axisY.setLabelFormat("%g") | |
axisY.setBase(8.0) | |
axisY.setMinorTickCount(-1) | |
chart.addAxis(axisY, QtCore.Qt.AlignLeft) | |
series.attachAxis(axisY) | |
chartview = QtChart.QChartView(chart) | |
self.setCentralWidget(chartview) | |
QtWidgets.QShortcut(QtGui.QKeySequence.ZoomOut, self, activated=chart.zoomOut) | |
QtWidgets.QShortcut(QtGui.QKeySequence.ZoomIn, self, activated=chart.zoomIn) | |
if __name__ == '__main__': | |
import sys | |
app = QtWidgets.QApplication(sys.argv) | |
w = Widget() | |
w.resize(640, 480) | |
w.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment