Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4794d80

Browse files
committed
Add translucent legend example from John Hunter's mailing list example.
svn path=/trunk/matplotlib/; revision=7279
1 parent 1ce5984 commit 4794d80

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/python
2+
#
3+
# Show how to add a translucent legend
4+
5+
# import pyplot module
6+
import matplotlib.pyplot as plt
7+
8+
# draw 2 crossing lines
9+
plt.plot([0,1], label='going up')
10+
plt.plot([1,0], label='going down')
11+
12+
# add the legend in the middle of the plot
13+
leg = plt.legend(fancybox=True, loc='center')
14+
# set the alpha value of the legend: it will be translucent
15+
leg.get_frame().set_alpha(0.5)
16+
17+
# show the plot
18+
plt.show()

0 commit comments

Comments
 (0)