File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 7
7
from . import color as mycol
8
8
from . import path as mypath
9
9
10
+ def get_legend_label_ (line ):
11
+ '''Check if line is in legend
12
+ '''
13
+
14
+ label = line .get_label ()
15
+ try :
16
+ ax = line .axes
17
+ leg = ax .get_legend ()
18
+ return label in [l .get_label () for l in leg .get_lines ()]
19
+ except AttributeError :
20
+ return None
10
21
11
22
def draw_line2d (data , obj ):
12
23
'''Returns the PGFPlots code for an Line2D environment.
@@ -97,6 +108,11 @@ def draw_line2d(data, obj):
97
108
if marker and not show_line :
98
109
addplot_options .append ('only marks' )
99
110
111
+ # Check if a line is not in a legend and forget it if so,
112
+ # fixes bug #167:
113
+ if not get_legend_label_ (obj ):
114
+ addplot_options .append ("forget plot" )
115
+
100
116
# process options
101
117
content .append ('\\ addplot ' )
102
118
if addplot_options :
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def plot():
24
24
25
25
def test ():
26
26
phash = helpers .Phash (plot ())
27
- assert phash .phash == 'eb785e0aaed6c190 ' , phash .get_details ()
27
+ assert phash .phash == 'eb785e0aaed68194 ' , phash .get_details ()
28
28
return
29
29
30
30
You can’t perform that action at this time.
0 commit comments