Skip to content
Snippets Groups Projects
Commit 2e683d48 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Make title an option, larger font

parent 8b5c1c5c
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ import matplotlib ...@@ -14,7 +14,7 @@ import matplotlib
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from matplotlib.widgets import Button, CheckButtons from matplotlib.widgets import Button, CheckButtons
from matplotlib.collections import LineCollection from matplotlib.collections import LineCollection
from matplotlib.dates import date2num, num2date, AutoDateFormatter from matplotlib.dates import date2num, num2date, ConciseDateFormatter
from matplotlib.figure import Figure from matplotlib.figure import Figure
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QComboBox from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QComboBox
...@@ -31,6 +31,7 @@ from datetime import datetime ...@@ -31,6 +31,7 @@ from datetime import datetime
from argparse import ArgumentParser from argparse import ArgumentParser
plt.rcParams.update({'font.size': 14})
class PowerPlot: class PowerPlot:
"""A power plot with two time scales""" """A power plot with two time scales"""
...@@ -42,8 +43,7 @@ class PowerPlot: ...@@ -42,8 +43,7 @@ class PowerPlot:
self.ax.set_ylabel(yname) self.ax.set_ylabel(yname)
self.ax.xaxis_date() self.ax.xaxis_date()
formatter = AutoDateFormatter(self.ax.xaxis.get_major_locator()) formatter = ConciseDateFormatter(self.ax.xaxis.get_major_locator())
formatter.scaled[1 / (24 * 60)] = "%H:%M"
self.ax.xaxis.set_major_formatter(formatter) self.ax.xaxis.set_major_formatter(formatter)
if offset is not None: if offset is not None:
...@@ -96,7 +96,7 @@ class MyToolbar(NavigationToolbar): ...@@ -96,7 +96,7 @@ class MyToolbar(NavigationToolbar):
class PowerPlotMainWindow(QMainWindow): class PowerPlotMainWindow(QMainWindow):
"""QT Application that reads data from stdin, plots in a PowerPlot""" """QT Application that reads data from stdin, plots in a PowerPlot"""
def __init__(self, offset=None, col_num=1, first_time=None, duration=2): def __init__(self, offset=None, col_num=1, first_time=None, duration=2, title=None):
super().__init__() super().__init__()
self.setStyleSheet("background-color: white;") self.setStyleSheet("background-color: white;")
self.autoscale_x = True self.autoscale_x = True
...@@ -155,7 +155,9 @@ class PowerPlotMainWindow(QMainWindow): ...@@ -155,7 +155,9 @@ class PowerPlotMainWindow(QMainWindow):
# fig.canvas.manager.set_window_title("Dwingeloo Radio Telescope") # fig.canvas.manager.set_window_title("Dwingeloo Radio Telescope")
self.powerplot = PowerPlot(fig, yname, offset=offset) if title is None:
title = yname
self.powerplot = PowerPlot(fig, title, offset=offset)
self.read_stdin() self.read_stdin()
self.stdin_notifier = QSocketNotifier( self.stdin_notifier = QSocketNotifier(
...@@ -210,6 +212,7 @@ if __name__ == "__main__": ...@@ -210,6 +212,7 @@ if __name__ == "__main__":
parser.add_argument("-o", "--offset", help="Offset along y-axis", type=float, default=None) parser.add_argument("-o", "--offset", help="Offset along y-axis", type=float, default=None)
parser.add_argument("-s", "--start", help="Start time (default: now)", type=datetime.fromisoformat, default=None) parser.add_argument("-s", "--start", help="Start time (default: now)", type=datetime.fromisoformat, default=None)
parser.add_argument("-d", "--duration", help="Duration in hours (default: 2", default=2, type=float) parser.add_argument("-d", "--duration", help="Duration in hours (default: 2", default=2, type=float)
parser.add_argument("-t", "--title", help="Plot title", default=None)
args = parser.parse_args() args = parser.parse_args()
...@@ -221,7 +224,7 @@ if __name__ == "__main__": ...@@ -221,7 +224,7 @@ if __name__ == "__main__":
app.setWindowIcon(QtGui.QIcon(icon_path)) app.setWindowIcon(QtGui.QIcon(icon_path))
except: except:
pass pass
main_window = PowerPlotMainWindow(offset=args.offset, first_time=args.start, duration=args.duration) main_window = PowerPlotMainWindow(offset=args.offset, first_time=args.start, duration=args.duration, title=args.title)
main_window.show() main_window.show()
signal.signal(signal.SIGINT, handle_interrupt_signal) signal.signal(signal.SIGINT, handle_interrupt_signal)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment