简体   繁体   中英

matplotlib label doesn't work

When I execute the following code, it doesn't produce a plot with a label.

import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 5)
plt.plot(x, x*1.5, label='Normal')

Numpy version is '1.6.2' Matplotlib version is '1.3.x'

Any ideas as to why this is happening?

You forgot to display the legend :

...
plt.legend(loc='best')
plt.show()

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM