Skip to content

Commit

Permalink
add xy plot
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed Mar 16, 2024
1 parent 4e674ca commit b97f766
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
39 changes: 39 additions & 0 deletions test/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ function plot1(X, Y; label="", width=2, xtickfontsize=12, ytickfontsize=12, lege
p
end

function plotxy(X, Y; xlabel="", ylabel, fig="")
if fig != ""
plt.figure(fig)
end
p = plt.plot(X, Y)
plt.xlabel(xlabel, fontsize=14);
plt.ylabel(ylabel, fontsize=14);
plt.grid(true)
plt.tight_layout()
end

function plot2(X, Y1, Y2; labels=["", ""], fig="", title="")
fig_ = plt.figure(fig, figsize=(8, 6))
ax1 = plt.subplot(211)
Expand Down Expand Up @@ -52,4 +63,32 @@ function plot3(X, Y1, Y2, Y3; labels=["", "", ""], fig="", title="")
plt.xlabel("time [s]", fontsize=14)
plt.xlim(0, X[end])
plt.tight_layout()
end

function plot4(X, Y1, Y2, Y3, Y4; labels=["", "", "", ""], fig="", title="")
fig_ = plt.figure(fig, figsize=(8, 6))
ax1 = plt.subplot(311)
plt.suptitle(title, fontsize=14) # Super title
plt.plot(X, Y1, label=labels[1]);
ylabel(labels[1], fontsize=14);
plt.grid(true)
plt.setp(ax1.get_xticklabels(), visible=false)
ax2 = plt.subplot(312, sharex = ax1)
plt.plot(X, Y2, label=labels[2])
plt.grid(true)
ylabel(labels[2], fontsize=14); grid(true)
plt.setp(ax2.get_xticklabels(), visible=false)
ax3 = plt.subplot(313, sharex = ax1)
plt.plot(X, Y3, label=labels[3])
plt.grid(true)
plt.ylabel(labels[3], fontsize=14);
plt.grid(true)
ax4 = plt.subplot(313, sharex = ax1)
plt.plot(X, Y4, label=labels[4])
plt.grid(true)
plt.ylabel(labels[4], fontsize=14);
plt.grid(true)
plt.xlabel("time [s]", fontsize=14)
plt.xlim(0, X[end])
plt.tight_layout()
end
4 changes: 1 addition & 3 deletions test/test_flightpathcontroller2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ plot3(TIME, PSI, BETA, PSI_DOT;
labels=["heading angle psi [°]", "elevation β [°]", "psi_dot [rad/s]"],
fig="test_fpc2")

# p5=plot(PHI, BETA, xlabel="azimuth ϕ [°]", ylabel="elevation β [°]", width=2, xtickfontsize=12, guidefontsize=18, ytickfontsize=12, legend=false)
# pIDR5 = display(p5) # Display with InspectDR and keep plot object
# resize!(pIDR5.wnd, 1000, 700) # Resize GTK window directly
plotxy(PHI, BETA, xlabel="azimuth ϕ [°]", ylabel="elevation β [°]", fig="test_fpc2_xy")

0 comments on commit b97f766

Please sign in to comment.