Adding Legend in Pymol

Every so often I have to label what each of those differently colored structures means when I get a snapshot in pymol. It gets a bit annoying when I have more than two structures.

Using matplotlib package, I can obtain the color of the structures and create those legends within pymol, can’t I?

Oh yes, yes I can. The below gist is the product of a quick test on Friday evening before I logged off for the weekend. In the process, I have learned that one simply does not create a list in pymol, but rather uses the `stored` object. It’s possible to modify this further and turn it into a function to create a custom legend with different selections. A super nice version would render the current view state and the legend together…

Easy to spend an entire day perfecting the function and lose track of the time. I will survive with this imperfect version for a while. You can see what it looks like in the snapshot at the top of this post.