Improved clear function to create realtime graphs