Factor out plot adding and fix issues

Opening this PR ASAP due to https://github.com/OpenTreeMap/OTM2/issues/1717, but it needs more documentation, testing, and integration with other bugfixes.