Skip to content

Commit 303850a

Browse files
committed
Fixes
1 parent 0998ff6 commit 303850a

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

ext/VortexStepMethodControlPlotsExt.jl

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module VortexStepMethodControlPlotsExt
22
using ControlPlots, LaTeXStrings, VortexStepMethod, LinearAlgebra, Statistics, DelimitedFiles
3+
using PythonCall: pyconvert
34
import ControlPlots: plt
45
import VortexStepMethod: calculate_filaments_for_plotting
56

@@ -22,7 +23,7 @@ Set the default style for plots using LaTeX.
2223
- `ùse_tex`: if the external `pdflatex` command shall be used
2324
"""
2425
function set_plot_style(titel_size=16; use_tex=false)
25-
rcParams = plt.PyDict(plt.matplotlib."rcParams")
26+
rcParams = plt.matplotlib."rcParams"
2627
rcParams["text.usetex"] = use_tex
2728
rcParams["font.family"] = "serif"
2829
if use_tex
@@ -99,7 +100,7 @@ Display a plot at specified DPI.
99100
# Keyword arguments
100101
- `dpi`: Dots per inch for the figure (default: 130)
101102
"""
102-
function VortexStepMethod.show_plot(fig::plt.Figure; dpi=130)
103+
function VortexStepMethod.show_plot(fig; dpi=130)
103104
fig.set_dpi(dpi)
104105
plt.display(fig)
105106
end
@@ -146,9 +147,9 @@ Set 3D plot axes to equal scale.
146147
zoom: zoom factor (default: 1.8)
147148
"""
148149
function set_axes_equal!(ax; zoom=1.8)
149-
x_lims = ax.get_xlim3d() ./ zoom
150-
y_lims = ax.get_ylim3d() ./ zoom
151-
z_lims = ax.get_zlim3d() ./ zoom
150+
x_lims = pyconvert(Vector{Float64}, ax.get_xlim3d()) ./ zoom
151+
y_lims = pyconvert(Vector{Float64}, ax.get_ylim3d()) ./ zoom
152+
z_lims = pyconvert(Vector{Float64}, ax.get_zlim3d()) ./ zoom
152153

153154
x_range = abs(x_lims[2] - x_lims[1])
154155
y_range = abs(y_lims[2] - y_lims[1])
@@ -218,15 +219,15 @@ function create_geometry_plot(body_aero::BodyAerodynamics, title, view_elevation
218219
ax.plot(x_corners,
219220
y_corners,
220221
z_corners,
221-
color=:grey,
222+
color="grey",
222223
linewidth=1,
223224
label=i == 1 ? "Panel Edges" : "")
224225

225226
# Plot control points and aerodynamic centers
226227
ax.scatter([control_points[i][1]], [control_points[i][2]], [control_points[i][3]],
227-
color=:green, label=i == 1 ? "Control Points" : "")
228+
color="green", label=i == 1 ? "Control Points" : "")
228229
ax.scatter([aero_centers[i][1]], [aero_centers[i][2]], [aero_centers[i][3]],
229-
color=:blue, label=i == 1 ? "Aerodynamic Centers" : "")
230+
color="blue", label=i == 1 ? "Aerodynamic Centers" : "")
230231

231232
# Plot filaments
232233
filaments = calculate_filaments_for_plotting(panel)
@@ -246,7 +247,7 @@ function create_geometry_plot(body_aero::BodyAerodynamics, title, view_elevation
246247
va_mag = norm(va)
247248
va_vector_begin = -2 * max_chord * va / va_mag
248249
va_vector_end = va_vector_begin + 1.5 * va / va_mag
249-
plot_line_segment!(ax, [va_vector_begin, va_vector_end], :lightblue, "va")
250+
plot_line_segment!(ax, [va_vector_begin, va_vector_end], "lightblue", "va")
250251

251252
# Add legends for the first occurrence of each label
252253
# by_label = Dict(zip(labels, handles))
@@ -650,8 +651,8 @@ function VortexStepMethod.plot_polars(
650651
(6, raw"$C_\mathrm{Mz}$", nothing, :cmz),
651652
]
652653
for (ax_idx, ylabel, pd_col, cm_field) in coeff_specs
653-
row = (ax_idx - 1) ÷ 3 + 1
654-
col = (ax_idx - 1) % 3 + 1
654+
row = (ax_idx - 1) ÷ 3
655+
col = (ax_idx - 1) % 3
655656
ax = axs[row, col]
656657
for (i, (polar_data, cm, label)) in enumerate(
657658
zip(polar_data_list, cm_data_list,
@@ -678,9 +679,9 @@ function VortexStepMethod.plot_polars(
678679
# 2x2 layout: CL, CD, CS, CL/CD or CL-vs-CD
679680
fig, axs = plt.subplots(2, 2, figsize=(14, 14))
680681
coeff_specs = [
681-
((1, 1), raw"$C_\mathrm{L}$", 2),
682-
((1, 2), raw"$C_\mathrm{D}$", 3),
683-
((2, 1), raw"$C_\mathrm{S}$", 4),
682+
((0, 0), raw"$C_\mathrm{L}$", 2),
683+
((0, 1), raw"$C_\mathrm{D}$", 3),
684+
((1, 0), raw"$C_\mathrm{S}$", 4),
684685
]
685686
for (pos, ylabel, pd_col) in coeff_specs
686687
ax = axs[pos...]
@@ -702,7 +703,7 @@ function VortexStepMethod.plot_polars(
702703
ax.legend()
703704
end
704705
# Fourth panel: CL/CD or CL-vs-CD
705-
ax4 = axs[2, 2]
706+
ax4 = axs[1, 1]
706707
for (i, (polar_data, label)) in enumerate(
707708
zip(polar_data_list, label_list))
708709
label, ls, mk, ms = format_label(

src/plotting_helpers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function generate_polar_data(
141141
end
142142

143143
polar_data = [
144-
angle_range, cl, cd, cs,
144+
collect(angle_range), cl, cd, cs,
145145
gamma_distribution, cl_distribution,
146146
cd_distribution, cs_distribution,
147147
reynolds_number

0 commit comments

Comments
 (0)