I guess the last batch might have another shape compared to the orhers, thus numpy cannot flatten the array properly.
Assuming your model output has the shape [batch_size, 1], try the following:
prediction_list.append(prediction.detach().cpu())
...
predictions = torch.cat(prediction_list).numpy().flatten()
plt.plot(predictions, 'b-')