It’s not clear to me what you actually want. What does “create custom legend” mean? Does “I” above refer to “you”, the developer of the plot, or “you” the viewer of the plot? Please explain in more detail what exactly it is that you want to happen in terms of user interactions.