From b2b6c9ed9bf4666dba21f8385383d3265629f61d Mon Sep 17 00:00:00 2001 From: Uwe Fechner Date: Fri, 12 Apr 2024 15:46:46 +0200 Subject: [PATCH] add param ysize --- src/ControlPlots.jl | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/ControlPlots.jl b/src/ControlPlots.jl index 7374c7b..0f55c0e 100644 --- a/src/ControlPlots.jl +++ b/src/ControlPlots.jl @@ -13,6 +13,7 @@ mutable struct PlotX labels xlabel ylabels + ysize fig type::Int64 end @@ -26,7 +27,7 @@ function load(filename::String) end function plot(X, Ys::AbstractVector{<:AbstractVector}; xlabel="", ylabel="", - labels=nothing, fig="", disp=false) + labels=nothing, fig="", ysize=14, disp=false) if disp if fig != "" plt.figure(fig) @@ -46,7 +47,7 @@ function plot(X, Ys::AbstractVector{<:AbstractVector}; xlabel="", ylabel="", plt.xlabel(xlabel, fontsize=14); end if ylabel != "" - plt.ylabel(ylabel, fontsize=14); + plt.ylabel(ylabel, fontsize=ysize); end plt.grid(true) plt.legend() @@ -54,15 +55,15 @@ function plot(X, Ys::AbstractVector{<:AbstractVector}; xlabel="", ylabel="", else println("OK") end - PlotX(X, Ys, labels, xlabel, ylabel, fig, 4) + PlotX(X, Ys, labels, xlabel, ylabel, ysize, fig, 4) end -function plot(Y::AbstractVector{<:Number}; xlabel="", ylabel="", fig="", disp=false) +function plot(Y::AbstractVector{<:Number}; xlabel="", ylabel="", fig="", ysize=14, disp=false) X = 1:length(Y) - plot(X, Y; xlabel, ylabel, fig, disp) + plot(X, Y; xlabel, ylabel, fig, disp, ysize) end -function plot(X, Y::AbstractVector{<:Number}; xlabel="", ylabel="", fig="", disp=false) +function plot(X, Y::AbstractVector{<:Number}; xlabel="", ylabel="", fig="", ysize=14, disp=false) if disp if fig != "" plt.figure(fig) @@ -71,15 +72,15 @@ function plot(X, Y::AbstractVector{<:Number}; xlabel="", ylabel="", fig="", disp if xlabel != "" plt.xlabel(xlabel, fontsize=14); end - plt.ylabel(ylabel, fontsize=14); + plt.ylabel(ylabel; fontsize=ysize); plt.xlim(X[begin], X[end]) plt.grid(true) plt.tight_layout() end - PlotX(X, Y, nothing, xlabel, ylabel, fig, 1) + PlotX(X, Y, nothing, xlabel, ylabel, ysize, fig, 1) end -function plotx(X, Y...; xlabel="time [s]", ylabels=nothing, fig="", title="", disp=false) +function plotx(X, Y...; xlabel="time [s]", ylabels=nothing, fig="", title="", ysize=14, disp=false) if disp len=length(Y) fig_ = plt.figure(fig, figsize=(8, len*2)) @@ -93,7 +94,7 @@ function plotx(X, Y...; xlabel="time [s]", ylabels=nothing, fig="", title="", di push!(ax, plt.subplot(subplot, sharex=ax[1])) end if i==1 - plt.suptitle(title, fontsize=14) # Super title + plt.suptitle(title; fontsize=14) # Super title end if ! isnothing(ylabels) lbl=ylabels[i] @@ -102,7 +103,7 @@ function plotx(X, Y...; xlabel="time [s]", ylabels=nothing, fig="", title="", di end plt.plot(X, y, label=lbl) plt.xlim(X[begin], X[end]) - plt.ylabel(lbl, fontsize=14); + plt.ylabel(lbl; fontsize=ysize); plt.grid(true) if i < len plt.setp(ax[i].get_xticklabels(), visible=false) @@ -113,32 +114,32 @@ function plotx(X, Y...; xlabel="time [s]", ylabels=nothing, fig="", title="", di plt.tight_layout() end - PlotX(collect(X), Y, nothing, xlabel, ylabels, fig, 2) + PlotX(collect(X), Y, nothing, xlabel, ylabels, ysize, fig, 2) end -function plotxy(X, Y; xlabel="", ylabel="", fig="", disp=false) +function plotxy(X, Y; xlabel="", ylabel="", fig="", ysize=14, disp=false) if disp if fig != "" plt.figure(fig, figsize=(6,6)) end plt.plot(X, Y) plt.xlabel(xlabel, fontsize=14); - plt.ylabel(ylabel, fontsize=14); + plt.ylabel(ylabel, fontsize=ysize); plt.grid(true) plt.tight_layout() end - PlotX(X, Y, nothing, xlabel, ylabel, fig, 3) + PlotX(X, Y, nothing, xlabel, ylabel, ysize, fig, 3) end function display(P::PlotX) if P.type == 1 - plot(P.X, P.Y; xlabel=P.xlabel, ylabel=P.ylabels, fig=P.fig, disp=true) + plot(P.X, P.Y; xlabel=P.xlabel, ylabel=P.ylabels, fig=P.fig, ysize=P.ysize, disp=true) elseif P.type == 2 - plotx(P.X, P.Y...; xlabel=P.xlabel, ylabels=P.ylabels, fig=P.fig, disp=true) + plotx(P.X, P.Y...; xlabel=P.xlabel, ylabels=P.ylabels, fig=P.fig, ysize=P.ysize, disp=true) elseif P.type == 3 - plotxy(P.X, P.Y; xlabel=P.xlabel, ylabel=P.ylabels, fig=P.fig, disp=true) + plotxy(P.X, P.Y; xlabel=P.xlabel, ylabel=P.ylabels, fig=P.fig, ysize=P.ysize, disp=true) else - plot(P.X, P.Y; xlabel=P.xlabel, labels=P.labels, fig=P.fig, disp=true) + plot(P.X, P.Y; xlabel=P.xlabel, labels=P.labels, fig=P.fig, ysize=P.ysize, disp=true) end plt.pause(0.01) plt.show(block=false)