@@ -60,8 +60,8 @@ def _apply_labels(
6060 y label. Default is None. if a string, autolabel is overwritten with ylabel
6161 data : WrightTools.data.Data object (optional)
6262 data to autolabel from. Default is None.
63- channel_index : integer (optional)
64- Channel index. Default is 0 .
63+ channel : WrightTools.data.Channel object (optional)
64+ Channel index. Default is None .
6565 """
6666 # read from data
6767 if autolabel in ["xy" , "both" , "x" ] and not xlabel :
@@ -514,17 +514,15 @@ def scatter(self, *args, **kwargs):
514514 Use `cmap` instead to control colors."
515515 )
516516
517- channel_ = data .get_channel (kwargs .pop ("channel" , 0 ))
518- channel = kwargs .pop ("channel" , 0 )
519- channel_index = wt_kit .get_index (data .channel_names , channel )
517+ channel = data .get_channel (kwargs .pop ("channel" , 0 ))
520518
521519 limits = {}
522- limits = self ._parse_limits (data = data , channel = channel_ , ** limits )
520+ limits = self ._parse_limits (data = data , channel = channel , ** limits )
523521 norm = Normalize (** limits )
524522
525- cmap = _parse_cmap (data , signed = channel_ .signed , ** kwargs )["cmap" ]
523+ cmap = _parse_cmap (data , signed = channel .signed , ** kwargs )["cmap" ]
526524
527- z = channel_ [:]
525+ z = channel [:]
528526
529527 # fill x, y, z to joint shape
530528 shape = wt_kit .joint_shape (z , * coords )
@@ -547,7 +545,7 @@ def full(arr, shape):
547545 xlabel = kwargs .pop ("xlabel" , None ),
548546 ylabel = kwargs .pop ("ylabel" , None ),
549547 data = data ,
550- channel = channel_ ,
548+ channel = channel ,
551549 )
552550
553551 return super ().scatter (* args , ** kwargs )
@@ -629,29 +627,27 @@ def plot(self, *args, **kwargs):
629627 # unpack data object, if given
630628 if isinstance (args [0 ], Data ):
631629 data = args .pop (0 )
632- channel = kwargs .pop ("channel" , 0 )
633- channel_index = wt_kit .get_index (data .channel_names , channel )
634- squeeze = np .array (data .channels [channel_index ].shape ) == 1
630+ channel = data .get_channel (kwargs .pop ("channel" , 0 ))
631+ squeeze = np .array (channel .shape ) == 1
635632 xa = data .axes [0 ]
636633 for sq , xs in zip (squeeze , xa .shape ):
637634 if sq and xs != 1 :
638635 raise wt_exceptions .ValueError ("Cannot squeeze axis to fit channel" )
639636 squeeze = tuple ([0 if i else slice (None ) for i in squeeze ])
640- zi = data . channels [ channel_index ] .points
637+ zi = channel .points
641638 xi = xa [squeeze ]
642639 if not zi .ndim == 1 :
643640 raise wt_exceptions .DimensionalityError (1 , zi .ndim )
644641 args = [xi , zi ] + args
645642 else :
646- data = None
647- channel_index = 0
643+ data = channel = None
648644 # labels
649645 self ._apply_labels (
650646 autolabel = kwargs .pop ("autolabel" , False ),
651647 xlabel = kwargs .pop ("xlabel" , None ),
652648 ylabel = kwargs .pop ("ylabel" , None ),
653649 data = data ,
654- channel = channel_ ,
650+ channel = channel ,
655651 )
656652 # call parent
657653 return super ().plot (* args , ** kwargs )
0 commit comments