Skip to content

Commit 22f7cf2

Browse files
authored
Merge pull request #25 from mahgadalla/dev
Tutorial-4 plot. elev and azim in Blade.plot
2 parents d7c33aa + b1a64dd commit 22f7cf2

File tree

4 files changed

+71
-21
lines changed

4 files changed

+71
-21
lines changed

bladex/blade.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,20 @@ def apply_transformations(self, reflect=True):
300300

301301
self._planar_to_cylindrical()
302302

303-
def plot(self, outfile=None):
303+
def plot(self, elev=None, azim=None, outfile=None):
304304
"""
305305
Plot the generated blade sections.
306306
307+
:param int elev: Set the view elevation of the axes. This can be used
308+
to rotate the axes programatically. 'elev' stores the elevation
309+
angle in the z plane. If elev is None, then the initial value is
310+
used which was specified in the mplot3d.Axes3D constructor. Default
311+
value is None
312+
:param int azim: Set the view azimuth angle of the axes. This can be
313+
used to rotate the axes programatically. 'azim' stores the azimuth
314+
angle in the x,y plane. If azim is None, then the initial value is
315+
used which was specified in the mplot3d.Axes3D constructor. Default
316+
value is None
307317
:param string outfile: save the plot if a filename string is provided.
308318
Default value is None.
309319
"""
@@ -329,6 +339,7 @@ def plot(self, outfile=None):
329339
ax.xaxis.label.set_color('red')
330340
ax.yaxis.label.set_color('red')
331341
ax.zaxis.label.set_color('red')
342+
ax.view_init(elev=elev, azim=azim)
332343

333344
if outfile:
334345
plt.savefig(outfile)

tests/test_blade.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,30 @@ def test_plot(self):
302302
blade.plot()
303303
plt.close()
304304

305+
def test_plot_view_elev_init(self):
306+
blade = create_sample_blade_NACA()
307+
blade.apply_transformations()
308+
blade.plot(elev=None)
309+
plt.close()
310+
311+
def test_plot_view_elev(self):
312+
blade = create_sample_blade_NACA()
313+
blade.apply_transformations()
314+
blade.plot(elev=45)
315+
plt.close()
316+
317+
def test_plot_view_azim_init(self):
318+
blade = create_sample_blade_NACA()
319+
blade.apply_transformations()
320+
blade.plot(azim=None)
321+
plt.close()
322+
323+
def test_plot_view_azim(self):
324+
blade = create_sample_blade_NACA()
325+
blade.apply_transformations()
326+
blade.plot(azim=-90)
327+
plt.close()
328+
305329
def test_plot_save(self):
306330
blade = create_sample_blade_NACA()
307331
blade.apply_transformations()

0 commit comments

Comments
 (0)