Plots.jlに関してREPLを使った少しお遊びの内容です。
バージョン1なので,gr()は省略します。
Juliaを立ち上げてPlotsモジュールを読み込みます。
_ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.10.2 (2024-03-01) _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release |__/ | julia> using Plots
Plotオブジェクトをpltに代入します。
julia> plt = plot(sin) Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
そして,plt.と入力してから↹キーを押します。
julia> plt.⭾
attr backend
init inset_subplots
layout n
o series_list
spmap subplots
と候補がでてきます。
backendを確認してみます。
julia> plt.backend Plots.GRBackend()
このように今のバックエンドが表示されます。
ということはこの方法で色々Plotオブジェクトの中身を確認できます。
attrを確認してみます。
julia> plt.attr RecipesPipeline.DefaultsDict with 30 entries: :dpi => 100 :background_color_outside => :match :plot_titlefontvalign => :vcenter :warn_on_unsupported => true :background_color => RGBA{Float64}(1.0,1.0,1.0,1.0) :inset_subplots => nothing :size => (600, 400) :display_type => :auto :overwrite_figure => true :html_output_format => :auto :plot_titlefontfamily => :match :plot_titleindex => 0 :foreground_color => RGB{N0f8}(0.0,0.0,0.0) :window_title => "Plots.jl" :plot_titlefontrotation => 0.0 :extra_plot_kwargs => Dict{Any, Any}() :pos => (0, 0) :plot_titlefonthalign => :hcenter :tex_output_standalone => false :extra_kwargs => :series :thickness_scaling => 1 :layout => 1 :plot_titlelocation => :center :plot_titlefontsize => 16 :plot_title => "" :show => false :link => :none :plot_titlefontcolor => :match :plot_titlevspan => 0.05 :fontfamily => "sans-serif"
Dict型のようなので,plt.attr[:layout]とかで内容の方を確認できます。
ここでは元に戻ってplt.subplotsの内容を確認します。
julia> plt.subplots
1-element Vector{Plots.Subplot}:
Subplot{1}
1個だけの配列のようです。一つ目を指定します。
julia> plt.subplots[1]
Subplot{1}
プロパティを確認してみます。plt.subplots[1].から⭾です。
julia> plt.subplots[1].⭾ attr bbox minpad o parent plotarea plt primary_series_count series_list
ここにもattrがあります。内容の方を確認してみます。
julia> plt.subplots[1].attr
RecipesPipeline.DefaultsDict with 79 entries:
:colorbar_titlefontrotation => 0.0
:top_margin => :match
:fontfamily_subplot => :match
:left_margin => :match
:legend_title_font => Font("sans-serif", 11, :hcenter, :vcenter, 0.0, RGB{N0f8}(0.0,0.0,0.…
:legend_font_halign => :hcenter
:legend_title_font_halign => :hcenter
:annotations => Any[]
:colorbar_titlefontfamily => :match
:legend_font => Font("sans-serif", 8, :hcenter, :vcenter, 0.0, RGB{N0f8}(0.0,0.0,0.0…
:annotationcolor => :match
:colorbar_tickfontcolor => :match
:projection_type => :auto
:colorbar_continuous_values => Float64[]
:margin => 1.0mm
:colorbar_tickfontfamily => :match
:annotationfontsize => 14
:foreground_color_title => :match
:bottom_margin => :match
:colorbar_tickfonthalign => :hcenter
:colorbar => :best
:annotationfontfamily => :match
:legend_font_family => :match
:framestyle => :axes
:legend_title_font_valign => :vcenter
:legend_position => :best
:legend_title => nothing
:colorbar_titlefonthalign => :hcenter
:legend_font_pointsize => 8
:subplot_index => 1
:title => ""
:colorbar_fontfamily => :match
:colorbar_titlefontvalign => :vcenter
⋮ => ⋮
subplotsにはseris_listというのもありました。確認してみます。
julia> plt.subplots[1].series_list
1-element Vector{Plots.Series}:
Plots.Series(RecipesPipeline.DefaultsDict(:plot_object => Plot{Plots.GRBackend() n=1}, :subplot => Subplot{1}, :label => "y1", :fillalpha => nothing, :linealpha => nothing, :linecolor => RGBA{Float64}(0.0,0.6056031611752245,0.9786801175696073,1.0), :x_extrema => (-5.0, 5.0), :series_index => 1, :markerstrokealpha => nothing, :markeralpha => nothing…))
1要素のVector型なので,1つ目を指定します。
julia> plt.subplots[1].series_list[1]
Plots.Series(RecipesPipeline.DefaultsDict(:plot_object => Plot{Plots.GRBackend() n=1}, :subplot => Subplot{1}, :label => "y1", :fillalpha => nothing, :linealpha => nothing, :linecolor => RGBA{Float64}(0.0,0.6056031611752245,0.9786801175696073,1.0), :x_extrema => (-5.0, 5.0), :series_index => 1, :markerstrokealpha => nothing, :markeralpha => nothing…))
series_list[1].でタブを押すと一つしか要素がないので補完されます。
そのまま内容を確認します。
julia> plt.subplots[1].series_list[1].plotattributes
RecipesPipeline.DefaultsDict with 62 entries:
:plot_object => Plot{Plots.GRBackend() n=1}
:subplot => Subplot{1}
:label => "y1"
:fillalpha => nothing
:linealpha => nothing
:linecolor => RGBA{Float64}(0.0,0.605603,0.97868,1.0)
:x_extrema => (-5.0, 5.0)
:series_index => 1
:markerstrokealpha => nothing
:markeralpha => nothing
:seriestype => :path
:z_extrema => (NaN, NaN)
:x => [-5.0, -4.98372, -4.96745, -4.95117, -4.93489, -4.85965, -4.7844, -4.74677, -4.70915, -4.67152 … 4.56269, 4.62854, 4.69439, 4.76023, 4.82608, 4.89193, 4.91895, 4.94596, 4.97298, 5.0]
:markerstrokecolor => RGBA{Float64}(0.0,0.0,0.0,1.0)
:fillcolor => RGBA{Float64}(0.0,0.605603,0.97868,1.0)
:clims_calculated => (NaN, NaN)
:seriescolor => RGBA{Float64}(0.0,0.605603,0.97868,1.0)
:extra_kwargs => Dict{Symbol, Any}()
:z => nothing
:series_plotindex => 1
:y => [0.958924, 0.963414, 0.967649, 0.971627, 0.975348, 0.989177, 0.997409, 0.999409, 0.999995, 0.999165 … -0.988816, -0.996487, -0.999838, -0.998856, -0.993544, -0.983926, -0.978743, -0.9…
:markercolor => RGBA{Float64}(0.0,0.605603,0.97868,1.0)
:y_extrema => (-0.99996, 0.999995)
:linewidth => 1
:group => nothing
:stride => (1, 1)
:permute => :none
:marker_z => nothing
:show_empty_bins => false
:seriesalpha => nothing
:smooth => false
:zerror => nothing
:arrow => nothing
⋮ => ⋮
...といった感じで,PlotsオブジェクトはREPLを使うとどんなアトリビュートや内容になっているかが 確認できます。
データも保管されているのは少し意外ですが,これを見るとたくさん図を描くとメモリをたくさん使いそうというのは何となく分かってきますね。
デフォルトのアトリビュート値が実際どうなっているかとかの確認とかに利用できそうです。