First of all, although in all cases it would have been better for you to talk to your professors outside of class and cultivate further intellectual/professional relationships with them, how much better depends a lot on the situation. For instance, in my academic field of mathematics, a student at a strong program who quietly does superior work in the most challenging courses available to her is going to get strong to very strong letters irrespective of the personal contact. In other academic fields, the most promising undergraduates will likely have some engagement with the research interests of the faculty, perhaps even to the extent of coauthorship on papers, and missing out on that may be missing out on a lot.
I am asking myself whether there are ways to improve a potential recommendation after having graduated.
It becomes a lot harder to improve your professors' opinions of you after you leave, for the obvious reasons: you have no more necessary points of contact with them, and they are no longer getting paid to teach and interact with you. Some faculty members are very generous with their time, but many faculty members
have packed their professional life with so many other activities that they literally don't have the time for more than casual interactions with former undergraduates.
Like, for example, through email correspondence, or sending the professor a paper I wrote, etc.?
You can try both of those things. Sending a paper you wrote that has some connection to the research interests of the professor in question sounds more promising to me than simply trying to raise their esteem via the enthusiasm and erudition of your epistles. (Sorry, I got a little carried away with the alliteration.) As above, a faculty member may not have time to do more than briefly glance at your paper...but even the brief glance of a professional can convince them that you're onto something and improve your letter.
Or should this ideally not influence the professor anymore?
No, you're fully entitled to take further steps to get a better letter. That may be hard to do, but the attempt is fully appropriate. Faculty will probably realize what you're doing (which is also okay...).