Debugged plot-samples function.