from matplotlib.colors import ListedColormap I'm looking for the cleanest way to put a sort of legend into a scatter. In the function _get_handles in legend.py, the symbol can be First, I have a feeling you meant to use apostrophes, not backticks when declaring colours. plot. I want a legend box that says " is something, is something, is something, next to my label?). Any suggestions? labels as I can with other kinds of plots, and for some reason legend for prints the text that I supply vertically (and of course it doesn't print There is a second way of creating a legend, in which you specify the "Label" for a set of points using a separate scatter command for each set. To learn more, see our tips on writing great answers. the or whatever). (1). Each element in the x, y and classes lists corresponds to one point in the plot. plot. When we want to put legend somewhere in a figure using Matplotlib, most of the time, the option loc='best' will produce the desired results. However, sometimes, we may want to have finer control over where the legend should be in the image. For example, we may want to put the legend outside of the axes, which is impossible using loc='best'. 'lines' can't be labeled (I think). this list! You can also use seaborn with a built-in colormap (which comes from matplotlib). First, I have a feeling you meant to use apostrophes, not backticks when declaring colours. For a legend you need some shapes as well as the classe Other answers seem a bit complex, you can just add a parameter 'label' in scatter function and that will be the legend for your plot. the or whatever). > is somethingelse" and so on. You can find other colormaps from Matplotlib colormap catalogue. If there's another way to make a legend, I wasn't able to find it after a few quick searches in the docs. Why do many companies reject expired SSL certificates as bugs in bug bounties? x = [1, 3, 4, 6, 7, 9] Euler: A baby on his lap, a cat on his back thats how he wrote his immortal works (origin?). One of them gives you legend entries for each thing you plot, and the other one lets you put whatever you want in the legend, stealing heavily from this answer. I had that vertical text problem when i first used legenduntil fig, ax = plt.subplots() Thanks. Is there a single-word adjective for "having exceptionally strong moral principles"? The ax.legend() function has more than one use, the first just creates the legend based on the lines in axes object, the second allwos you to control the entries manually, and is described here. For example, I have a list of x and y values, and a list of classes values. is somethingelse" and so Since the legends were covering datapoints I moved them, and the locations for legends can be found here.