@@ -25,7 +25,7 @@ def __init__(self, aero_surface):
2525 self .aero_surface = aero_surface
2626
2727 @abstractmethod
28- def draw (self , * , filename = None ):
28+ def draw (self , vis_args = None , * , filename = None ):
2929 pass
3030
3131 def lift (self ):
@@ -54,7 +54,7 @@ class _NoseConePlots(_AeroSurfacePlots):
5454 """Class that contains all nosecone plots. This class inherits from the
5555 _AeroSurfacePlots class."""
5656
57- def draw (self , * , filename = None ):
57+ def draw (self , vis_args = None , * , filename = None ):
5858 """Draw the nosecone shape along with some important information,
5959 including the center line and the center of pressure position.
6060
@@ -73,14 +73,17 @@ def draw(self, *, filename=None):
7373 # Create the vectors X and Y with the points of the curve
7474 nosecone_x , nosecone_y = self .aero_surface .shape_vec
7575
76+ if vis_args is None :
77+ vis_args = {}
78+
7679 # Figure creation and set up
7780 _ , ax = plt .subplots ()
7881 ax .set_xlim (- 0.05 , self .aero_surface .length * 1.02 ) # Horizontal size
7982 ax .set_ylim (
8083 - self .aero_surface .base_radius * 1.05 , self .aero_surface .base_radius * 1.05
8184 ) # Vertical size
8285 ax .set_aspect ("equal" ) # Makes the graduation be the same on both axis
83- ax .set_facecolor (" #EEEEEE" ) # Background color
86+ ax .set_facecolor (vis_args . get ( "background" , " #EEEEEE") ) # Background color
8487 ax .grid (True , linestyle = "--" , linewidth = 0.5 )
8588
8689 cp_plot = (self .aero_surface .cpz , 0 )
@@ -140,7 +143,7 @@ class _FinsPlots(_AeroSurfacePlots):
140143 _AeroSurfacePlots class."""
141144
142145 @abstractmethod
143- def draw (self , * , filename = None ):
146+ def draw (self , vis_args = None , * , filename = None ):
144147 pass
145148
146149 def airfoil (self ):
@@ -201,7 +204,7 @@ class _TrapezoidalFinsPlots(_FinsPlots):
201204 """Class that contains all trapezoidal fin plots."""
202205
203206 # pylint: disable=too-many-statements
204- def draw (self , * , filename = None ):
207+ def draw (self , vis_args = None , * , filename = None ):
205208 """Draw the fin shape along with some important information, including
206209 the center line, the quarter line and the center of pressure position.
207210
@@ -291,10 +294,14 @@ def draw(self, *, filename=None):
291294 label = "Mean Aerodynamic Chord" ,
292295 )
293296
297+ if vis_args is None :
298+ vis_args = {}
299+
294300 # Plotting
295301 fig = plt .figure (figsize = (7 , 4 ))
296302 with plt .style .context ("bmh" ):
297303 ax = fig .add_subplot (111 )
304+ fig .patch .set_facecolor (vis_args .get ("background" , "#EEEEEE" ))
298305
299306 # Fin
300307 ax .add_line (leading_edge )
@@ -330,7 +337,7 @@ class _EllipticalFinsPlots(_FinsPlots):
330337 """Class that contains all elliptical fin plots."""
331338
332339 # pylint: disable=too-many-statements
333- def draw (self , * , filename = None ):
340+ def draw (self , vis_args = None , * , filename = None ):
334341 """Draw the fin shape along with some important information.
335342 These being: the center line and the center of pressure position.
336343
@@ -383,10 +390,14 @@ def draw(self, *, filename=None):
383390 # Center of pressure
384391 cp_point = [self .aero_surface .cpz , self .aero_surface .Yma ]
385392
393+ if vis_args is None :
394+ vis_args = {}
395+
386396 # Plotting
387397 fig = plt .figure (figsize = (7 , 4 ))
388398 with plt .style .context ("bmh" ):
389399 ax = fig .add_subplot (111 )
400+ fig .patch .set_facecolor (vis_args .get ("background" , "#EEEEEE" ))
390401 ax .add_patch (ellipse )
391402 ax .add_line (yma_line )
392403 ax .add_line (center_line )
@@ -409,7 +420,7 @@ class _FreeFormFinsPlots(_FinsPlots):
409420 """Class that contains all free form fin plots."""
410421
411422 # pylint: disable=too-many-statements
412- def draw (self , * , filename = None ):
423+ def draw (self , vis_args = None , * , filename = None ):
413424 """Draw the fin shape along with some important information.
414425 These being: the center line and the center of pressure position.
415426
@@ -443,10 +454,14 @@ def draw(self, *, filename=None):
443454 label = "Mean Aerodynamic Chord" ,
444455 )
445456
457+ if vis_args is None :
458+ vis_args = {}
459+
446460 # Plotting
447461 fig = plt .figure (figsize = (7 , 4 ))
448462 with plt .style .context ("bmh" ):
449463 ax = fig .add_subplot (111 )
464+ fig .patch .set_facecolor (vis_args .get ("background" , "#EEEEEE" ))
450465
451466 # Fin
452467 ax .scatter (
@@ -483,7 +498,7 @@ def draw(self, *, filename=None):
483498class _TailPlots (_AeroSurfacePlots ):
484499 """Class that contains all tail plots."""
485500
486- def draw (self , * , filename = None ):
501+ def draw (self , vis_args = None , * , filename = None ):
487502 # This will de done in the future
488503 pass
489504
@@ -498,7 +513,7 @@ def drag_coefficient_curve(self):
498513 else :
499514 return self .aero_surface .drag_coefficient .plot ()
500515
501- def draw (self , * , filename = None ):
516+ def draw (self , vis_args = None , * , filename = None ):
502517 raise NotImplementedError
503518
504519 def all (self ):
@@ -514,12 +529,12 @@ def all(self):
514529class _GenericSurfacePlots (_AeroSurfacePlots ):
515530 """Class that contains all generic surface plots."""
516531
517- def draw (self , * , filename = None ):
532+ def draw (self , vis_args = None , * , filename = None ):
518533 pass
519534
520535
521536class _LinearGenericSurfacePlots (_AeroSurfacePlots ):
522537 """Class that contains all linear generic surface plots."""
523538
524- def draw (self , * , filename = None ):
539+ def draw (self , vis_args = None , * , filename = None ):
525540 pass
0 commit comments