Moved plotting function inside RealTimeGraph