Answers for "change legend size matplotlib"

4

legend size matplotlib

plt.plot([1, 2, 3], label='Inline label')
plt.legend(loc=1, prop={'size': 16})
Posted by: Guest on July-01-2020
0

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()
Posted by: Guest on May-29-2021
0

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]
Posted by: Guest on May-29-2021

Code answers related to "change legend size matplotlib"

Python Answers by Framework

Browse Popular Code Answers by Language