Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef5e858

Browse files
committed
Move data getting
1 parent04d772f commitef5e858

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

‎src/napari_matplotlib/features.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
fromtypingimportDict,List,Optional
1+
fromtypingimportAny,Dict,List,Optional,Tuple
22

33
importnapari
44
importnapari.layers
5+
importnumpyasnp
6+
importnumpy.typingasnpt
7+
importpandasaspd
58
fromqtpy.QtWidgetsimportQComboBox,QLabel,QVBoxLayout
69

710
fromnapari_matplotlib.baseimportNapariMPLWidget
@@ -86,6 +89,27 @@ def _ready_to_plot(self) -> bool:
8689
andall([self.get_key(dim)invalid_keysfordiminself.dims])
8790
)
8891

92+
def_get_data_names(
93+
self,
94+
)->Tuple[List[npt.NDArray[Any]],List[str]]:
95+
"""
96+
Get the plot data from the ``features`` attribute of the first
97+
selected layer.
98+
99+
Returns
100+
-------
101+
data : List[np.ndarray]
102+
List contains X and Y columns from the FeatureTable. Returns
103+
an empty array if nothing to plot.
104+
names : List[str]
105+
Names for each axis.
106+
"""
107+
feature_table:pd.DataFrame=self.layers[0].features
108+
109+
names= [str(self.get_key(dim))fordiminself.dims]
110+
data= [np.array(feature_table[key])forkeyinnames]
111+
returndata,names
112+
89113
defon_update_layers(self)->None:
90114
"""
91115
Called when the layer selection changes by ``self.update_layers()``.

‎src/napari_matplotlib/scatter.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,5 @@ def draw(self) -> None:
108108
super().draw()
109109

110110
def_get_data(self)->Tuple[npt.NDArray[Any],npt.NDArray[Any],str,str]:
111-
"""
112-
Get the plot data from the ``features`` attribute of the first
113-
selected layer.
114-
115-
Returns
116-
-------
117-
data : List[np.ndarray]
118-
List contains X and Y columns from the FeatureTable. Returns
119-
an empty array if nothing to plot.
120-
x_axis_name : str
121-
The title to display on the x axis. Returns
122-
an empty string if nothing to plot.
123-
y_axis_name: str
124-
The title to display on the y axis. Returns
125-
an empty string if nothing to plot.
126-
"""
127-
feature_table=self.layers[0].features
128-
129-
x=feature_table[self.get_key("x")]
130-
y=feature_table[self.get_key("y")]
131-
132-
x_axis_name=str(self.get_key("x"))
133-
y_axis_name=str(self.get_key("y"))
134-
135-
returnx,y,x_axis_name,y_axis_name
111+
data,names=self._get_data_names()
112+
returndata[0],data[1],names[0],names[1]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp