Skip to content

Commit dde66e5

Browse files
committed
overwrite colors in plot3d:
- if 'color' argument is given to the plot3d, it will overwrite lines and raft elements to that color. Useful if need to compare two 3d plots in one figure axis. - parameter description to the function was given.
1 parent ef1be13 commit dde66e5

File tree

2 files changed

+57
-13
lines changed

2 files changed

+57
-13
lines changed

famodel/mooring/mooring.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def update(self, dd=None):
204204

205205

206206
def setSectionLength(self, L, i):
207-
'''Sets length of section, including in the subdsystem if there is
207+
'''Sets length of section, including in the subsystem if there is
208208
one.'''
209209
sec = self.getSubcomponent(self.i_sec[i])
210210
sec['L'] = L # set length in dd (which is also Section/subcomponent)
@@ -214,15 +214,15 @@ def setSectionLength(self, L, i):
214214

215215
"""
216216
def setSectionDiameter(self, d, i):
217-
'''Adjusts diameter of section (including in the subdsystem if there is
217+
'''Adjusts diameter of section (including in the subsystem if there is
218218
one, since it should point to the lineType dict in the Mooring.'''
219219
220220
# just adjust the dict? ss.lineTypes should already point to it
221221
self.sectionType[i].update( setLineType( ... d))
222222
"""
223223

224224
def setSectionType(self, lineType, i):
225-
'''Sets lineType of section, including in the subdsystem
225+
'''Sets lineType of section, including in the subsystem
226226
if there is one.'''
227227
sec = self.getSubcomponent(self.i_sec[i])
228228
# set type dict in dd (which is also Section/subcomponent)

famodel/project.py

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,19 +2449,60 @@ def plot2d(self, ax=None, plot_seabed=False, plot_soil=False,
24492449

24502450
def plot3d(self, ax=None, figsize=(10,8), plot_fowt=False, save=False,
24512451
plot_boundary=True, plot_boundary_on_bath=True, args_bath={},
2452-
plot_axes=True, plot_bathymetry=True, plot_soil=False,
2452+
plot_axes=True, plot_bathymetry=True, plot_soil=False, color=None,
24532453
colorbar=True, boundary_only=False,**kwargs):
24542454
'''Plot aspects of the Project object in matplotlib in 3D.
24552455
24562456
TODO - harmonize a lot of the seabed stuff with MoorPy System.plot...
24572457
24582458
Parameters
24592459
----------
2460-
...
2460+
ax : matplotlib.axes._subplots.Axes3DSubplot, optional
2461+
The 3D axes object to plot on. If None, a new figure and axes will be created.
2462+
2463+
figsize : tuple, optional
2464+
The size of the figure in inches, specified as (width, height). Default is (10, 8).
2465+
2466+
plot_fowt : bool, optional
2467+
Whether to plot the floating offshore wind turbine (FOWT) in the 3D visualization. Default is False.
2468+
2469+
save : bool, optional
2470+
Whether to save the plot to a file. Default is False.
2471+
2472+
plot_boundary : bool, optional
2473+
Whether to plot the project boundary in the 3D visualization. Default is True.
2474+
2475+
plot_boundary_on_bath : bool, optional
2476+
Whether to overlay the project boundary on the bathymetry plot. Default is True.
2477+
2478+
args_bath : dict, optional
2479+
Additional arguments to customize the bathymetry plot, such as contour levels or color maps. Default is an empty dictionary.
2480+
2481+
plot_axes : bool, optional
2482+
Whether to display the 3D axes in the plot. Default is True.
2483+
2484+
plot_bathymetry : bool, optional
2485+
Whether to include the bathymetry (seabed depth) in the 3D visualization. Default is True.
2486+
2487+
plot_soil : bool, optional
2488+
Whether to include soil properties or layers in the 3D visualization. Default is False.
2489+
2490+
color : str or matplotlib color, optional
2491+
The color to use for certain plot elements (lines and raft members - maybe cable too?). If None, default colors will be used. Default is None.
2492+
2493+
colorbar : bool, optional
2494+
Whether to include a colorbar in the plot (e.g., for bathymetry). Default is True.
2495+
2496+
boundary_only : bool, optional
2497+
If True, only the project boundary will be plotted, ignoring other elements. Default is False.
2498+
2499+
**kwargs : dict, optional
2500+
Additional keyword arguments passed to the underlying matplotlib plotting functions.
24612501
24622502
Returns
24632503
-------
2464-
ax : figure axes
2504+
ax : matplotlib.axes._subplots.Axes3DSubplot
2505+
The 3D axes object containing the plot.
24652506
'''
24662507

24672508
# color map for soil plotting
@@ -2640,14 +2681,17 @@ def plot3d(self, ax=None, figsize=(10,8), plot_fowt=False, save=False,
26402681
#mooring.subsystem.plot(ax = ax, draw_seabed=False)
26412682
if mooring.ss:
26422683
for line in mooring.ss.lineList:
2643-
if 'chain' in line.type['material']:
2644-
line.color = 'k'
2645-
elif 'polyester' in line.type['material']:
2646-
line.color = [.3,.5,.5]
2684+
if color: # overwrite if color is given.
2685+
line.color = color
26472686
else:
2648-
line.color = [0.5,0.5,0.5]
2687+
if 'chain' in line.type['material']:
2688+
line.color = 'k'
2689+
elif 'polyester' in line.type['material']:
2690+
line.color = [.3,.5,.5]
2691+
else:
2692+
line.color = [0.5,0.5,0.5]
26492693
line.lw = lw
2650-
mooring.ss.drawLine(0, ax, color='self')
2694+
mooring.ss.drawLine(0, ax, color=color)
26512695
elif mooring.parallels:
26522696
for i in mooring.i_sec:
26532697
sec = mooring.getSubcomponent(i)
@@ -2665,7 +2709,7 @@ def plot3d(self, ax=None, figsize=(10,8), plot_fowt=False, save=False,
26652709
# plot the FOWTs using a RAFT FOWT if one is passed in (TEMPORARY)
26662710
if plot_fowt:
26672711
for pf in self.array.fowtList:
2668-
pf.plot(ax,zorder=6,plot_ms=False, axes_around_fowt=False)
2712+
pf.plot(ax, color=color, zorder=6,plot_ms=False, axes_around_fowt=False)
26692713
# for i in range(self.nt):
26702714
# xy = self.turb_coords[i,:]
26712715
# fowt.setPosition([xy[0], xy[1], 0,0,0,0])

0 commit comments

Comments
 (0)