Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

change markersize in legend matplotlib

lgnd = plt.legend(loc="lower left", scatterpoints=1, fontsize=10)
lgnd.legendHandles[0]._sizes = [30]
lgnd.legendHandles[1]._sizes = [30]
Comment

change markersize in legend matplotlib

import matplotlib.pyplot as plt
import numpy as np

def rand_data():
    return np.random.uniform(low=0., high=1., size=(100,))

# Generate data.
x1, y1 = [rand_data() for i in range(2)]
x2, y2 = [rand_data() for i in range(2)]

plt.figure()
plt.plot(x1, y1, 'o', label='first', markersize=np.sqrt(20.), c='b')
plt.plot(x2, y2, 'o', label='second', markersize=np.sqrt(35.), c='r')
# Plot legend.
lgnd = plt.legend(loc="lower left", numpoints=1, fontsize=10)

#change the marker size manually for both lines
lgnd.legendHandles[0]._legmarker.set_markersize(6)
lgnd.legendHandles[1]._legmarker.set_markersize(6)
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: python terminal progress bar 
Python :: how to strip whitespace in python 
Python :: create a database in python 
Python :: convert string to number python 
Python :: pandas transform 
Python :: nested ternary operator python 
Python :: How to filter with Regex in Django ORM 
Python :: keras loss plot 
Python :: confusion matrix 
Python :: pygame bg color 
Python :: pandas df.to_csv() accent in columns name 
Python :: download latest chromedriver python code 
Python :: condition in python 
Python :: snake water gun game in python 
Python :: fizz buzz in python 
Python :: upload bytes to s3 python 
Python :: python list index() 
Python :: tkinter canas can you use other fonts 
Python :: how to print a newline in python 
Python :: list of lists to table python 
Python :: matplotlib pie chart order 
Python :: print dtype of numpy array 
Python :: unsupervised knn 
Python :: python get object name 
Python :: python s3 
Python :: sumof product 1 
Python :: download python libraries offline 
Python :: how to download file using python using progress bar 
Python :: example of break statement in python 
Python :: flask abort 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =