1313import matplotlib .pyplot as plt
1414from matplotlib import cm
1515import plotly .graph_objects as go
16+ import pandas as pd
17+ from typing import Tuple
1618from czitools .utils import logging_tools
1719
1820logger = logging_tools .set_logging ()
1921
2022
2123def scatterplot_mpl (
22- planetable ,
23- s = 0 ,
24- t = 0 ,
25- z = 0 ,
26- c = 0 ,
27- msz2d = 35 ,
28- normz = True ,
29- fig1savename = "zsurface2d.png" ,
30- fig2savename = "zsurface3d.png" ,
31- msz3d = 20 ,
32- ):
24+ planetable : pd . DataFrame ,
25+ s : int = 0 ,
26+ t : int = 0 ,
27+ z : int = 0 ,
28+ c : int = 0 ,
29+ msz2d : int = 35 ,
30+ normz : bool = True ,
31+ fig1savename : str = "zsurface2d.png" ,
32+ fig2savename : str = "zsurface3d.png" ,
33+ msz3d : int = 20 ,
34+ ) -> Tuple [ plt . Figure , plt . Figure ] :
3335 """
3436 Generates 2D and 3D scatter plots of XYZ positions from a given table and saves them as PNG files.
3537 Parameters:
@@ -77,7 +79,7 @@ def scatterplot_mpl(
7779 xpos = planetable ["X[micron]" ]
7880 ypos = planetable ["Y[micron]" ]
7981 zpos = planetable ["Z[micron]" ]
80- except KeyError as e :
82+ except KeyError :
8183 xpos = planetable ["X [micron]" ]
8284 ypos = planetable ["Y [micron]" ]
8385 zpos = planetable ["Z [micron]" ]
@@ -124,13 +126,9 @@ def scatterplot_mpl(
124126
125127 # add a label
126128 if normz :
127- cb1 .set_label (
128- "Z-Offset [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal"
129- )
129+ cb1 .set_label ("Z-Offset [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal" )
130130 if not normz :
131- cb1 .set_label (
132- "Z-Position [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal"
133- )
131+ cb1 .set_label ("Z-Position [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal" )
134132
135133 # save figure as PNG
136134 fig1 .savefig (fig1savename , dpi = 100 )
@@ -164,13 +162,9 @@ def scatterplot_mpl(
164162 cb2 = plt .colorbar (sc2 , shrink = 0.8 )
165163 # add a label
166164 if normz :
167- cb2 .set_label (
168- "Z-Offset [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal"
169- )
165+ cb2 .set_label ("Z-Offset [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal" )
170166 if not normz :
171- cb2 .set_label (
172- "Z-Position [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal"
173- )
167+ cb2 .set_label ("Z-Position [micron]" , labelpad = 20 , fontsize = 12 , fontweight = "normal" )
174168
175169 # save figure as PNG
176170 fig2 .savefig (fig2savename , dpi = 100 )
@@ -180,17 +174,17 @@ def scatterplot_mpl(
180174
181175
182176def scatterplot_plotly (
183- planetable ,
184- s = 0 ,
185- t = 0 ,
186- z = 0 ,
187- c = 0 ,
188- msz2d = 35 ,
189- normz = True ,
190- fig1savename = "zsurface2d.html" ,
191- fig2savename = "zsurface3d.html" ,
192- msz3d = 20 ,
193- ):
177+ planetable : pd . DataFrame ,
178+ s : int = 0 ,
179+ t : int = 0 ,
180+ z : int = 0 ,
181+ c : int = 0 ,
182+ msz2d : int = 35 ,
183+ normz : bool = True ,
184+ fig1savename : str = "zsurface2d.html" ,
185+ fig2savename : str = "zsurface3d.html" ,
186+ msz3d : int = 20 ,
187+ ) -> Tuple [ go . Figure , go . Figure ] :
194188 """
195189 Generates 2D and 3D scatter plots using Plotly and saves them as HTML files.
196190 Parameters:
@@ -228,7 +222,7 @@ def scatterplot_plotly(
228222 xpos = planetable ["X[micron]" ]
229223 ypos = planetable ["Y[micron]" ]
230224 zpos = planetable ["Z[micron]" ]
231- except KeyError as e :
225+ except KeyError :
232226 xpos = planetable ["X [micron]" ]
233227 ypos = planetable ["Y [micron]" ]
234228 zpos = planetable ["Z [micron]" ]
@@ -256,9 +250,7 @@ def scatterplot_plotly(
256250 colorscale = "Viridis" ,
257251 line_width = 2 ,
258252 showscale = True ,
259- colorbar = dict (
260- thickness = 10 , title = dict (text = scalebar_title , side = "right" )
261- ),
253+ colorbar = dict (thickness = 10 , title = dict (text = scalebar_title , side = "right" )),
262254 ),
263255 )
264256 )
@@ -289,9 +281,7 @@ def scatterplot_plotly(
289281 color = zpos ,
290282 colorscale = "Viridis" ,
291283 opacity = 0.8 ,
292- colorbar = dict (
293- thickness = 10 , title = dict (text = scalebar_title , side = "right" )
294- ),
284+ colorbar = dict (thickness = 10 , title = dict (text = scalebar_title , side = "right" )),
295285 ),
296286 )
297287 ]
0 commit comments