Android - How to fix a sudden increase in battery drain?

I tried lots of things but in the end only a factory data reset of the phone worked.

Before I did the reset the battery drain looked like this in Settings > Battery:

battery drain before factory reset

The shallow gradient was when I booted the phone in safe mode. This at least suggested the issue was likely to to with one or more apps rather than something inherently wrong with the phone.

GSam Battery Monitor wasn't much use. All it told me was that Google Services or Google Play Services was draining the battery but it didn't tell me which app(s) were causing that.

So I opted for a factory reset of the phone data and installed apps manually, just one or two at a time, watching the battery drain in Settings > Battery to make sure the newly installed app wasn't suddenly increasing battery drain. I'd wait at least 12 hours before installing another one or two apps. So this approach takes a lot of patience and isn't very practical if you use your phone for many things in the mean time. But now my battery life has increased from just half a day to 4 to 5 days...

battery drain after factory reset

I don't know whether this could've been fixed without a factory reset, or what app or setting caused the battery drain to increase suddenly in the first place. Ideally there would be some way of getting a breakdown of battery drain within Google (Play) Services due to different apps invoking it.