10
10
11
11
import numpy as npy
12
12
13
- import agg
14
13
import numerix .ma as ma
15
14
from matplotlib import verbose
16
15
import artist
17
16
from artist import Artist , setp
18
17
from cbook import iterable , is_string_like , is_numlike
19
18
from colors import colorConverter
20
- from transforms import Bbox
19
+ from path import Path
20
+ from transforms import Affine2D , Bbox
21
21
22
22
from matplotlib import rcParams
23
23
@@ -284,9 +284,6 @@ def __init__(self, xdata, ydata,
284
284
self .set_data (xdata , ydata )
285
285
self ._logcache = None
286
286
287
- # TODO: do we really need 'newstyle'
288
- self ._newstyle = False
289
-
290
287
def contains (self , mouseevent ):
291
288
"""Test whether the mouse event occurred on the line. The pick radius determines
292
289
the precision of the location test (usually within five points of the value). Use
@@ -427,6 +424,7 @@ def recache(self):
427
424
if len (x ) != len (y ):
428
425
raise RuntimeError ('xdata and ydata must be the same length' )
429
426
427
+ # MGDTODO: Deal with segments
430
428
mx = ma .getmask (x )
431
429
my = ma .getmask (y )
432
430
mask = ma .mask_or (mx , my )
@@ -439,7 +437,9 @@ def recache(self):
439
437
440
438
self ._x = npy .asarray (x , float )
441
439
self ._y = npy .asarray (y , float )
442
-
440
+ self ._path = Path (npy .vstack ((self ._x , self ._y )).transpose (),
441
+ closed = False )
442
+
443
443
self ._logcache = None
444
444
445
445
@@ -508,38 +508,27 @@ def draw(self, renderer):
508
508
gc .set_joinstyle (join )
509
509
gc .set_capstyle (cap )
510
510
511
- if self ._newstyle :
512
- # transform in backend
513
- xt = self ._x
514
- yt = self ._y
515
- else :
516
- x , y = self ._get_plottable ()
517
- if len (x )== 0 : return
518
- xt , yt = self .get_transform ().numerix_x_y (x , y )
519
-
520
-
521
-
522
511
funcname = self ._lineStyles .get (self ._linestyle , '_draw_nothing' )
523
512
lineFunc = getattr (self , funcname )
524
513
514
+ # MGDTODO: Deal with self._segments
525
515
if self ._segments is not None :
526
516
for ii in self ._segments :
527
517
lineFunc (renderer , gc , xt [ii [0 ]:ii [1 ]], yt [ii [0 ]:ii [1 ]])
528
518
529
519
else :
530
- lineFunc (renderer , gc , xt , yt )
531
-
532
-
533
- if self ._marker is not None :
534
-
520
+ lineFunc (renderer , gc , self ._path )
521
+
522
+ # MGDTODO: Deal with markers
523
+ if self ._marker is not None and False :
535
524
gc = renderer .new_gc ()
536
525
self ._set_gc_clip (gc )
537
526
gc .set_foreground (self .get_markeredgecolor ())
538
527
gc .set_linewidth (self ._markeredgewidth )
539
528
gc .set_alpha (self ._alpha )
540
529
funcname = self ._markers .get (self ._marker , '_draw_nothing' )
541
530
markerFunc = getattr (self , funcname )
542
- markerFunc (renderer , gc , xt , yt )
531
+ markerFunc (renderer , gc , self . _path )
543
532
544
533
#renderer.close_group('line2d')
545
534
@@ -720,7 +709,7 @@ def set_dashes(self, seq):
720
709
self .set_linestyle ('--' )
721
710
self ._dashSeq = seq # TODO: offset ignored for now
722
711
723
- def _draw_nothing (self , renderer , gc , xt , yt ):
712
+ def _draw_nothing (self , renderer , gc , path ):
724
713
pass
725
714
726
715
def _draw_steps (self , renderer , gc , xt , yt ):
@@ -737,13 +726,10 @@ def _draw_steps(self, renderer, gc, xt, yt):
737
726
else :
738
727
renderer .draw_lines (gc , xt2 , yt2 )
739
728
740
- def _draw_solid (self , renderer , gc , xt , yt ):
741
- if len (xt )< 2 : return
729
+ def _draw_solid (self , renderer , gc , path ):
730
+ # if len(xt)<2: return
742
731
gc .set_linestyle ('solid' )
743
- if self ._newstyle :
744
- renderer .draw_lines (gc , xt , yt , self .get_transform ())
745
- else :
746
- renderer .draw_lines (gc , xt , yt )
732
+ renderer .draw_path (gc , path , self .get_transform ())
747
733
748
734
749
735
def _draw_dashed (self , renderer , gc , xt , yt ):
@@ -1103,16 +1089,12 @@ def _draw_tickright(self, renderer, gc, xt, yt):
1103
1089
for (x ,y ) in zip (xt , yt ):
1104
1090
renderer .draw_line (gc , x , y , x + offset , y )
1105
1091
1092
+ _tickup_path = Path ([[- 0.5 , 0.0 ], [- 0.5 , 1.0 ]])
1106
1093
def _draw_tickup (self , renderer , gc , xt , yt ):
1107
1094
offset = renderer .points_to_pixels (self ._markersize )
1108
- if self ._newstyle :
1109
- path = agg .path_storage ()
1110
- path .move_to (- 0.5 , 0 )
1111
- path .line_to (- 0.5 , offset )
1112
- renderer .draw_markers (gc , path , None , xt , yt , self .get_transform ())
1113
- else :
1114
- for (x ,y ) in zip (xt , yt ):
1115
- renderer .draw_line (gc , x , y , x , y + offset )
1095
+ marker_transform = Affine2D ().scale (1.0 , offset )
1096
+ renderer .draw_markers (gc , self ._tickup_path , marker_transform ,
1097
+ self ._path , self .get_transform ())
1116
1098
1117
1099
def _draw_tickdown (self , renderer , gc , xt , yt ):
1118
1100
offset = renderer .points_to_pixels (self ._markersize )
0 commit comments