Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

matplotlib legend out of plot

ax.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05),
          ncol=3, fancybox=True, shadow=True)
Comment

matplotlib legend

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 20, 1000)
y1 = np.sin(x)
y2 = np.cos(x)

plt.plot(x, y1, "-b", label="sine")
plt.plot(x, y2, "-r", label="cosine")
plt.legend(loc="upper left")
plt.ylim(-1.5, 2.0)
plt.show()
Comment

position of legend matplotlib

plt.legend(loc='upper right')
Comment

plt.legend(

plt.legend(['first', 'second']);
Comment

matplotlib location legend

plt.legend(loc='best')
plt.legend(loc='upper right')
plt.legend(loc='Center left')
plt.legend(loc='Upper center')
# etc.
Comment

legend matplotlib


import matplotlib.pyplot as plt

#define x and ysin
plt.plot(x,ysin,label='sin(x)')
plt.legend()
plt.show()
Comment

legend ax matplotlib

ax.plot([1, 2, 3], label='Inline label')
ax.legend()
Comment

PREVIOUS NEXT
Code Example
Python :: marks input using list in python 
Python :: Print Table Using While Loop In Python 
Python :: remove word from string python 
Python :: remove single and double quotes from string python 
Python :: pandas convert date to string 
Python :: pydrive list folders 
Python :: python get all images in directory 
Python :: plotly add hline dashed 
Python :: python float to string n decimals 
Python :: how to edit a specific line in text file in python 
Python :: python open file exception 
Python :: change background color of tkinter 
Python :: pandas remove index column when saving to csv 
Python :: generate matrix python 
Python :: python two while loops at same time 
Python :: join two numpy 2d array 
Python :: how to find the lowest value in a nested list python 
Python :: python play mp3 in background 
Python :: matplotlib wrap title 
Python :: python filter in ailst 
Python :: jupyter plot not showing 
Python :: pandas ttable with sum totals 
Python :: write object to file python 
Python :: turn off pycache python 
Python :: python method to filter vowels in a string 
Python :: multiple args for pandas apply 
Python :: python paramiko check ssh connection 
Python :: how to get the user ip in djagno 
Python :: find out current datetime in python 
Python :: reading a csv file in python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =