Skip to content

Commit ed1681c

Browse files
committed
Better plots
1 parent f36085b commit ed1681c

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

bladex/profilebase.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,26 +540,27 @@ def plot(self,
540540
raise ValueError('One or all the coordinates have None value.')
541541

542542
if profile:
543-
plt.plot(self.xup_coordinates, self.yup_coordinates)
544-
plt.plot(self.xdown_coordinates, self.ydown_coordinates)
543+
plt.plot(self.xup_coordinates, self.yup_coordinates, label='Upper profile')
544+
plt.plot(self.xdown_coordinates, self.ydown_coordinates, label='Lower profile')
545545

546546
if chord_line:
547547
if self.chord_line is None:
548548
raise ValueError(
549549
'Chord line is None. You must compute it first')
550-
plt.plot(self.chord_line[0], self.chord_line[1])
550+
plt.plot(self.chord_line[0], self.chord_line[1], label='Chord line')
551551

552552
if camber_line:
553553
if self.camber_line is None:
554554
raise ValueError(
555555
'Camber line is None. You must compute it first')
556-
plt.plot(self.camber_line[0], self.camber_line[1])
556+
plt.plot(self.camber_line[0], self.camber_line[1], label='Camber line')
557557

558558
if ref_point:
559-
plt.scatter(self.reference_point[0], self.reference_point[1])
559+
plt.scatter(self.reference_point[0], self.reference_point[1], s=15, label='Reference point')
560560

561561
plt.grid(linestyle='dotted')
562562
plt.axis('equal')
563+
plt.legend()
563564

564565
if outfile:
565566
if not isinstance(outfile, str):

tests/test_profilebase.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,18 @@ def test_plot_ref_point(self):
529529
outfile=None)
530530
plt.close()
531531

532+
def test_plot_all(self):
533+
profile = create_sample_profile()
534+
profile.compute_camber_line()
535+
profile.compute_chord_line()
536+
profile.plot(
537+
profile=True,
538+
chord_line=True,
539+
camber_line=True,
540+
ref_point=True,
541+
outfile=None)
542+
plt.close()
543+
532544
def test_plot_save(self):
533545
profile = create_sample_profile()
534546
profile.plot(outfile='tests/test_datasets/test_plot.png')

0 commit comments

Comments
 (0)