python scatter plot legend

Solutions on MaxInterview for python scatter plot legend by the best coders in the world

showing results for - "python scatter plot legend"
Adriana
13 Oct 2017
1# credit to the Stack Overflow user in the source link
2
3import matplotlib.pyplot as plt
4from numpy.random import random
5
6colors = ['b', 'c', 'y', 'm', 'r']
7
8lo = plt.scatter(random(10), random(10), marker='x', color=colors[0])
9ll = plt.scatter(random(10), random(10), marker='o', color=colors[0])
10l  = plt.scatter(random(10), random(10), marker='o', color=colors[1])
11a  = plt.scatter(random(10), random(10), marker='o', color=colors[2])
12h  = plt.scatter(random(10), random(10), marker='o', color=colors[3])
13hh = plt.scatter(random(10), random(10), marker='o', color=colors[4])
14ho = plt.scatter(random(10), random(10), marker='x', color=colors[4])
15
16plt.legend((lo, ll, l, a, h, hh, ho),
17           ('Low Outlier', 'LoLo', 'Lo', 'Average', 'Hi', 'HiHi', 'High Outlier'),
18           scatterpoints=1,
19           loc='lower left',
20           ncol=3,
21           fontsize=8)
22
23plt.show()
queries leading to this page
matplotlib scatter plot with legendlegend size scatter plotpyplot scatter legendadding legend to scatter plot in pythonplt legend scatter plotmatplotlib scatterplot legendscatter plot display legendpython plt add manually legend scatterscatter plots legend elementsadding legend to scatter plot in python plotlyhow to retrieve legend entry from scatter pyplotscatter plot python legendadd legend scatter plot matplotlibcustom matplotlib legend for scatter plotscatter plot add legendlegend scatterplotlegend scatter plot matplotlibhow to add legend in scatter plot in pythonmatplotlib scatter plot legend colorlegend python scatterplt scatter legendspecify legend in plt scatterscatter legend elements 28 29 5b0 5d matplotlibscatter matplotlib legendlegend color in scatter with matplotlibplt scatterplot legendadd legend matplotlib scatterscatter plot python color legendgenerate legend for plt scatter plotdf plot scatter legendscatter plot point legend3d scatter plot python legendmatplotlib scatter plot legend legend in scatter pythonscatter plot numpy legendaxes scatter legendmatplotlib scatter legendget legend in scatter plothow to add legend in scatter plot pythonhow to add a legend to a scatter plot in pythonhow to add legend in matplotlib scatter plotsmatplotlib scatter and line legendmatplotlib scatter plot legend for each pointhow to add scatter plot custom legend in pythonplot scatter plot legend rscatter plot how to place the legend box in pythonplt scatter legend generatelegend for scatter plotadd legend to scatter plotpx scatter show legend in figurepython plt scatter legendlegend scatterplot matplotlibadd legend to scatter plot matplotlibplt scatter legendget legend entry from scatter pyplotlegend seaborn scatterplotpython plt manually add legend scatterscatter plot legendascatter legendscatter plot legend matplotlibmatplotlib scatter color legendlegend for scatter plot pythonlegend in scatter plot pythonhow to add legend in matplotlib pyplot scatter plotsmatplotlib legend for scatter plot of two different colorascatter legend elements matplotlibcreate legend on scatter plotpython matplotlib scatter plot legendscatterplot legendseaborn scatterplot legendlegend title scatterplotlabel order in legend for scatter and plot matplotlibmatplot lib scatter legend for each colorscatter scatter legendscatterplot legend in matplotlliblegend in plt scatter plotplt legend scatterlegend python scatter graphscatter plot plt legendplt scatter color legendhow to make a legend in matplotlib scatter 27legend in scatter plot matplotlibmatplotlib scatter show color legendscatter plot matplotlib legendplt scatter legend pythonplt scatter plot with legendlabel in plt scatter for legendscatter plot seaborn legendscatter plot legendscatter plot python use of legendlegend in scatter plotscatter with legendpython scatter plot legendplt legend scatter plotscatter plot legend stylepd plotting scatter matrix legendadd a color legend to matplotlib scatter plotscatter plot legend pythonhow to add legend to scatter plot in pythonmatplotlib scatter plot legend by valueplt legend scatter plot pythonpython scatter plot legend