@@ -64,7 +64,7 @@ def load_data(fname: str, args: dict) -> np.ndarray:
6464 )
6565
6666
67- def plot_plot (fig : Any , x : np .ndarray , Y : np .ndarray , label : str ) -> Any :
67+ def plot_plot (fig : Any , x : np .ndarray , y : np .ndarray , label : str ) -> Any :
6868 """Make the plot-figures.
6969
7070 plot_plot() is generating a single- or multi-plot by recursively calling plot().
@@ -75,8 +75,8 @@ def plot_plot(fig: Any, x: np.ndarray, Y: np.ndarray, label: str) -> Any:
7575 Figure class for the terminal plot
7676 x : float-array
7777 1D-Numpy-array with the float column x-values.
78- Y : float-array
79- 1D- or 2D-Numpy-array with the float column Y -values.
78+ y : float-array
79+ 1D- or 2D-Numpy-array with the float column y -values.
8080 label : str
8181 The label of the plot(s) is the current filename.
8282
@@ -85,16 +85,16 @@ def plot_plot(fig: Any, x: np.ndarray, Y: np.ndarray, label: str) -> Any:
8585 fig : class
8686 Updated figure class for the terminal plot
8787 plot_plot() : function
88- Returns the function itself for a smaller (n-1) float-array (Y ) until it is an
88+ Returns the function itself for a smaller (n-1) float-array (y ) until it is an
8989 1D-array.
9090 """
91- fig .plot (x , Y [:, 0 ], label = label )
92- if Y .shape [1 ] == 1 :
91+ fig .plot (x , y [:, 0 ], label = label )
92+ if y .shape [1 ] == 1 :
9393 return fig
94- return plot_plot (fig , x , Y [:, 1 :], label = label )
94+ return plot_plot (fig , x , y [:, 1 :], label = label )
9595
9696
97- def plot_scatter (fig , x : np .ndarray , Y : np .ndarray , label : str ):
97+ def plot_scatter (fig , x : np .ndarray , y : np .ndarray , label : str ):
9898 """Make the scatter-figures.
9999
100100 plot_scatter() is generating a single- or multi-plot by recursive calling
@@ -106,8 +106,8 @@ def plot_scatter(fig, x: np.ndarray, Y: np.ndarray, label: str):
106106 Figure class for the terminal plot
107107 x : np.ndarray
108108 1D-Numpy-array with the float column x-values.
109- Y : np.ndarray
110- 1D- or 2D-Numpy-array with the float column Y -values.
109+ y : np.ndarray
110+ 1D- or 2D-Numpy-array with the float column y -values.
111111 label : str
112112 The label of the scatter-plot(s) is the current filename.
113113
@@ -116,13 +116,34 @@ def plot_scatter(fig, x: np.ndarray, Y: np.ndarray, label: str):
116116 fig : class
117117 Updated figure class for the terminal plot
118118 plot_scatter() : function
119- Returns the function itself for a smaller (n-1) float-array (Y ) until it is an
119+ Returns the function itself for a smaller (n-1) float-array (y ) until it is an
120120 1D-array.
121121 """
122- fig .scatter (x , Y [:, 0 ], label = label )
123- if Y .shape [1 ] == 1 :
122+ fig .scatter (x , y [:, 0 ], label = label )
123+ if y .shape [1 ] == 1 :
124124 return fig
125- return plot_plot (fig , x , Y [:, 1 :], label = label )
125+ return plot_scatter (fig , x , y [:, 1 :], label = label )
126+
127+
128+ def fig_size (width : float , height : float ) -> Any :
129+ """Set the figure size.
130+
131+ Parameters
132+ ----------
133+ width : float
134+ Width of the terminal plot.
135+ height : float
136+ Height of the terminal plot.
137+
138+ Returns
139+ -------
140+ fig : class
141+ Figure class for the terminal plot
142+ """
143+ fig = plt .Figure ()
144+ fig .width = width
145+ fig .height = height
146+ return fig
126147
127148
128149def plot (data : np .ndarray , args : dict , label : str ) -> None :
@@ -140,9 +161,7 @@ def plot(data: np.ndarray, args: dict, label: str) -> None:
140161 label : str
141162 The label of the scatter-plot(s) is the current filename.
142163 """
143- fig = plt .Figure ()
144- fig .width = args ["size" ][0 ]
145- fig .height = args ["size" ][1 ]
164+ fig = fig_size (width = args ["size" ][0 ], height = args ["size" ][1 ])
146165 try :
147166
148167 if args ["x_limits" ]:
@@ -167,14 +186,12 @@ def plot(data: np.ndarray, args: dict, label: str) -> None:
167186 y = data [:, 1 :]
168187
169188 if args ["scatter" ]:
170- fig = plot_scatter (fig , x = x , Y = y , label = label )
189+ fig = plot_scatter (fig , x = x , y = y , label = label )
171190 else :
172- fig = plot_plot (fig , x = x , Y = y , label = label )
191+ fig = plot_plot (fig , x = x , y = y , label = label )
192+
193+ log (fig .show (legend = args ["legend" ]))
173194
174- if args ["legend" ]:
175- log (fig .show (legend = True ))
176- else :
177- log (fig .show (legend = False ))
178195 except IndexError :
179196 log (f"corrupted data in { label } " , mode = 1 )
180197 sys .exit (1 )
@@ -351,7 +368,3 @@ def command_line_runner() -> None:
351368
352369 fnames = args ["infile" ]
353370 bashplot (fnames , args )
354-
355-
356- if __name__ == "__main__" :
357- command_line_runner ()
0 commit comments