Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python scatter plot legend

# credit to the Stack Overflow user in the source link

import matplotlib.pyplot as plt
from numpy.random import random

colors = ['b', 'c', 'y', 'm', 'r']

lo = plt.scatter(random(10), random(10), marker='x', color=colors[0])
ll = plt.scatter(random(10), random(10), marker='o', color=colors[0])
l  = plt.scatter(random(10), random(10), marker='o', color=colors[1])
a  = plt.scatter(random(10), random(10), marker='o', color=colors[2])
h  = plt.scatter(random(10), random(10), marker='o', color=colors[3])
hh = plt.scatter(random(10), random(10), marker='o', color=colors[4])
ho = plt.scatter(random(10), random(10), marker='x', color=colors[4])

plt.legend((lo, ll, l, a, h, hh, ho),
           ('Low Outlier', 'LoLo', 'Lo', 'Average', 'Hi', 'HiHi', 'High Outlier'),
           scatterpoints=1,
           loc='lower left',
           ncol=3,
           fontsize=8)

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: python sorted dictionary multiple keys 
Python :: how store list in django session 
Python :: anaconda snake 
Python :: shebang python 
Python :: In file included from psycopg/psycopgmodule.c:28:./psycopg/psycopg.h:35:10: fatal error: Python.h: No such file or directory35 | #include <Python.h| ^~~~~~~~~~compilation terminated. 
Python :: dense rank in pandas 
Python :: python google chrome 
Python :: np vstack 
Python :: python loop list from last to first 
Python :: python log10 
Python :: remove add button django admin 
Python :: django radio button 
Python :: exclude index column pandas 
Python :: how to round off values in columns in pandas in excel 
Python :: python verzeichnis erstellen 
Python :: pandas pad method 
Python :: how to find unique values in a column in pandas 
Python :: remove a column from dataframe 
Python :: python file reading 
Python :: web crawler using python 
Python :: Create list with numbers between 2 values by 
Python :: templateDoesNotExist Django 
Python :: ipywidget datepicker 
Python :: how to get unique value of all columns in pandas 
Python :: set header in dataframe 2nd line 
Python :: tensorflow_version 
Python :: python classes 
Python :: how to disconnect wifi using python 
Python :: how to add rows to empty dataframe 
Python :: python time library 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =