@@ -2163,6 +2163,8 @@ def plot2d(self, ax=None, plot_seabed=False,draw_soil=False,plot_bathymetry=True
21632163 ...
21642164 bare : bool
21652165 If True, supress display of extra labeling like the colorbar.
2166+ color_lineDepth: bool
2167+ If True, color mooring lines based on depth. Only works if plot_bathymetry=False.
21662168 '''
21672169
21682170 # Handle extra keyword arguments or use default values
@@ -2183,7 +2185,7 @@ def plot2d(self, ax=None, plot_seabed=False,draw_soil=False,plot_bathymetry=True
21832185 show_legend = kwargs .get ('show_legend' , True )
21842186
21852187 max_line_depth = kwargs .get ('max_line_depth' , None ) # max depth for line coloring if color_lineDepth is True
2186-
2188+ only_shared = kwargs . get ( 'only_shared' , False ) # if color_lineDepth is True, only color shared lines
21872189 # if axes not passed in, make a new figure
21882190 if ax == None :
21892191 fig , ax = plt .subplots (1 ,1 , figsize = figsize )
@@ -2251,16 +2253,15 @@ def plot2d(self, ax=None, plot_seabed=False,draw_soil=False,plot_bathymetry=True
22512253 ax .fill (env ['x' ], env ['y' ], edgecolor = edgecolor , facecolor = 'none' , linestyle = 'dashed' , lw = 0.8 , label = 'Platform Envelope' )
22522254
22532255 if plot_moorings :
2254- depth_cmap_settings = None
2256+ line_depth_settings = None
22552257 if color_lineDepth :
2256- if max_line_depth is None :
2257- bath_depth = True
22582258 if plot_bathymetry :
22592259 raise ValueError ("Cannot use depth-based line coloring with plot_bathymetry=True. Disable bathymetry to avoid confusion." )
2260- depth_cmap_settings = {
2260+ line_depth_settings = {
22612261 "cmap" : "Blues" ,
22622262 "vmin" : max_line_depth if max_line_depth else - np .max (self .grid_depth ),
2263- "vmax" : 0
2263+ "vmax" : 0 ,
2264+ "only_shared" : only_shared
22642265 }
22652266 for mooring in self .mooringList .values ():
22662267 for name , env in mooring .envelopes .items ():
@@ -2296,23 +2297,23 @@ def plot2d(self, ax=None, plot_seabed=False,draw_soil=False,plot_bathymetry=True
22962297
22972298 if mooring .ss :
22982299 mooring .ss .drawLine2d (0 , ax , color = "self" , endpoints = False ,
2299- Xuvec = [1 ,0 ,0 ], Yuvec = [0 ,1 ,0 ], depth_cmap_settings = depth_cmap_settings , label = labs )
2300+ Xuvec = [1 ,0 ,0 ], Yuvec = [0 ,1 ,0 ], line_depth_settings = line_depth_settings , label = labs )
23002301 elif mooring .parallels :
23012302 for i ,line in enumerate (lineList ):
23022303 line .drawLine2d (0 , ax , color = "self" ,
2303- Xuvec = [1 ,0 ,0 ], Yuvec = [0 ,1 ,0 ], depth_cmap_settings = depth_cmap_settings , label = labs [i ])
2304+ Xuvec = [1 ,0 ,0 ], Yuvec = [0 ,1 ,0 ], line_depth_settings = line_depth_settings , label = labs [i ])
23042305
23052306 else : # simple line plot
23062307 ax .plot ([mooring .rA [0 ], mooring .rB [0 ]],
23072308 [mooring .rA [1 ], mooring .rB [1 ]], 'k' , lw = 0.5 , label = 'Mooring Line' )
23082309
23092310 # ---- Add colorbar for line depth ----
2310- if depth_cmap_settings is not None and not bare :
2311+ if line_depth_settings is not None and not bare :
23112312 import matplotlib .cm as cm
23122313 import matplotlib .colors as mcolors
2313- sm = cm .ScalarMappable (cmap = cm .get_cmap (depth_cmap_settings ["cmap" ]),
2314- norm = mcolors .Normalize (vmin = depth_cmap_settings ["vmin" ],
2315- vmax = depth_cmap_settings ["vmax" ]))
2314+ sm = cm .ScalarMappable (cmap = cm .get_cmap (line_depth_settings ["cmap" ]),
2315+ norm = mcolors .Normalize (vmin = line_depth_settings ["vmin" ],
2316+ vmax = line_depth_settings ["vmax" ]))
23162317 sm .set_array ([])
23172318 cbar = plt .colorbar (sm , ax = ax , fraction = 0.04 )
23182319 cbar .set_label ("Line Depth (m)" )
0 commit comments