Skip to content

Commit

Permalink
fix xlims and ylims
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Fechner committed May 3, 2024
1 parent b08c46c commit 84f38ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mwes/mwe_03.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ x_max = maximum(x)
z_max = maximum(z)

xlabel = "x [m]"
plot(x, z; xlabel, ylabel="z [m]", xlims = (x_max-15.0, x_max+5), ylims = (z_max-15.0, z_max+5))
p=plot(x, z; xlabel, ylabel="z [m]", xlims = (x_max-15.0, x_max+5), ylims = (z_max-15.0, z_max+5))
13 changes: 12 additions & 1 deletion src/ControlPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ function plot(X, Ys::AbstractVector{<:AbstractVector}; xlabel="", ylabel="",
if ylabel != ""
plt.ylabel(ylabel, fontsize=ysize);
end
if ! isnothing(xlims)
println("xlims: $xlims")
plt.xlim(xlims)
end
plt.grid(true)
plt.legend()
plt.tight_layout()
Expand All @@ -75,7 +79,14 @@ function plot(X, Y::AbstractVector{<:Number}; xlabel="", ylabel="", xlims=nothin
plt.xlabel(xlabel, fontsize=14);
end
plt.ylabel(ylabel; fontsize=ysize);
plt.xlim(X[begin], X[end])
if isnothing(xlims)
plt.xlim(X[begin], X[end])
else
plt.xlim(xlims)
end
if ! isnothing(ylims)
plt.ylim(ylims)
end
plt.grid(true)
plt.tight_layout()
end
Expand Down

0 comments on commit 84f38ef

Please sign in to comment.