Skip to content
Advertisement

How can I move the legend from the plot to the appropriate place? [closed]

membership function membership function in fuzzy algorithm and the place of the legend is wrong how I can change it’s place

Advertisement

Answer

For your image if you use matplotlib, using loc=’upper center’ or loc=’best’

import numpy as np
import matplotlib.pyplot as plt
  
plt.plot(x, y1, label ='1')
plt.plot(x, y2, label ='2')
  
# Function add a legend  
plt.legend(loc='upper center')
  
# function to show the plot
plt.show()

But if you want to put it in a specific x,y coordinate

plt.legend(loc='upper right', bbox_to_anchor=(x, y))
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement