Fix bug causing the plot to crash