Skip to content

Instantly share code, notes, and snippets.

@donkarlo
Created September 8, 2022 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donkarlo/ba153bb2e2333ea4c65a11d3aa52105e to your computer and use it in GitHub Desktop.
Save donkarlo/ba153bb2e2333ea4c65a11d3aa52105e to your computer and use it in GitHub Desktop.
cvzxc
import matplotlib
# test scenario abn compute
import numpy as np
from matplotlib import pyplot as plt
import PyQt5
class PlotAll:
def __init__(self):
matplotlib.use("Qt5Agg")
plt.ion()
self.__fig, self.__axes = plt.subplots(3, 1)
self.__lineRobot1Pos, = self.__axes[0].plot(np.random.randn(100), np.random.randn(100))
self.__lineRobot2Pos, = self.__axes[0].plot(np.random.randn(100), np.random.randn(100))
self.__axes[0].set_title("Position")
self.__lineLidar, = self.__axes[1].plot(np.random.randn(100))
self.__axes[1].set_title("Lidar abnormality")
self.__lineGps, = self.__axes[2].plot(np.random.randn(100))
self.__axes[2].set_title("GPS abnormality")
plt.show(block=False)
def updateGpsPlot(self, robot1GpsTimeRows,robot2GpsTimeRows):
self.__lineRobot1Pos.set_xdata(robot1GpsTimeRows[:, 1])
self.__lineRobot1Pos.set_ydata(robot1GpsTimeRows[:, 2])
self.__lineRobot2Pos.set_xdata(robot2GpsTimeRows[:, 1])
self.__lineRobot2Pos.set_ydata(robot2GpsTimeRows[:, 2])
self.__axes[0].relim()
self.__axes[0].autoscale_view()
self.__fig.canvas.update()
self.__fig.canvas.flush_events()
def updateGpsAbnPlot(self, gpsTimeAbnVals):
self.__lineGps.set_xdata(gpsTimeAbnVals[:, 0])
self.__lineGps.set_ydata(gpsTimeAbnVals[:, 1])
self.__axes[2].relim()
self.__axes[2].autoscale_view()
self.__fig.canvas.update()
self.__fig.canvas.flush_events()
def updateLidarAbnPlot(self, lidarTimeAbnVals):
self.__lineLidar.set_xdata(lidarTimeAbnVals[:, 0])
self.__lineLidar.set_ydata(lidarTimeAbnVals[:, 1])
self.__axes[1].relim()
self.__axes[1].autoscale_view()
self.__fig.canvas.update()
self.__fig.canvas.flush_events()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment