Takuya Miyashita
This site
Web
Start:
*Plots メモ [#p2e2f2c3]
#contents
**Plots について [#occbadc0]
Julia には様々な図の作成方法があるらしい.~
その中で Plots は,他の描画ツールをバックエンドとして,Pl...
メリットは,同じコードでもバックエンドを切り替えるだけで...
バックエンドを切り替えてみて,見栄えの良い図をその都度選...
下記リンクにあるように,(ほぼ)同じ文構造で図を作成できる.
-[[GR バックエンド>https://docs.juliaplots.org/latest/gal...
-[[PyPlot バックエンド>https://docs.juliaplots.org/latest...
-[[PlotlyJS バックエンド>https://docs.juliaplots.org/late...
MATLAB や Python の matplotlib に近いので,これらに慣れて...
ただし,PyPlot というパッケージがあるので matplotlib 以外...
~
~
**図作成の基本 [#oe847565]
Plots の図の書き方は原則2種類ある.~
plot で始まり,seriestype (linetype) 引数でスタイルを指定...
#codeprettify(lang-julia){{
using Plots
}}
を宣言して,scatter は
#codeprettify(lang-julia){{
plot(x, y, seriestype=scatter) # or
scatter(x,y)
}}
contour は
#codeprettify(lang-julia){{
plot(X, Y, Z, seriestype=contour) # or
contour(X,Y,Z)
}}
という感じ.バックエンドによってはできないスタイルもある.~
(呼び出しているだけであり,バックエンド本体の範疇を超える...
contour や surface 系の平面図については,MATLAB や matplo...
X, Y がベクトル(Vector, Array{T,1})でなければならない点に...
~
~
**体裁の整え方 [#z525e4e4]
#codeprettify(lang-julia){{
plot(; color=(:plasma), xlims=(0,1), ylims=(0,1), label="...
}}
のように plot のキーワード引数を使う方法と
#codeprettify(lang-julia){{
plot(...)
xlims!(0,1)
ylims!(0,1)
}}
または
#codeprettify(lang-julia){{
plt = plot(...)
plt = plot!(plt, xlims=(0,1), ylims=(0,1))
}}
のように後付けする方法がある.~
[[Attributes>http://docs.juliaplots.org/latest/attributes...
引数の型が Tuple か普通の Array かよくわからなくなった時...
~
~
**線やマーカーの色の取得 [#gc85472d]
線やマーカで使う(:auto で決まる)色を予め取得する場合.~
#codeprettify(lang-julia){{
c = palette(:auto)
}}
のようにする.~
~
~
**マーカーの設定 [#ge62e820]
キーワード引数は marker (エイリアスの m や mark も可)で,...
#codeprettify(lang-julia){{
scatter!(plt, x, y; marker=(:magenta, 0.8, Plots.stroke(1...
}}
[[Attributes>https://docs.juliaplots.org/latest/attribute...
~
~
**複数の図を1枚に表示 [#s41fa3df]
別々に作成した Plots.Plot 型の図を subplot のように使う.~
事前にレイアウトを決定する必要がなく,後で決められるのが...
pltA と pltB を並べる時は
#codeprettify(lang-julia){{
# pltA::T, pltB::T where T <: Plots.Plot を 2x1 (縦 x 横)...
plts = plot(pltA, pltB, layout=(2,1), size=(600,600))
}}
結合した図の大きさはキーワード引数 size を使って調整する.~
この結合を複数回行うことで,(n x m) に限らず任意の配置で...
ただし,バックエンドによっては対応していなかったり図がぐ...
~
~
**(GR) リモートサーバーでの出力エラー [#c14aa673]
ssh で入っているコンピュータに対して処理をしたい時に,表...
画像ファイルとして出力しようにも,このエラーによって阻ま...
#codeprettify(lang-julia){{
ENV["GKSwstype"]="nul"
}}
または
#codeprettify(lang-julia){{
ENV["GKSwstype"]=100
}}
とすると,エラー回避できる.
~
~
**余白(margin)の設定 [#r1c6f0d5]
キーワード引数 margin を使う.~
4つのそれぞれの margin を指定したければ,bottom_margin, t...
#codeprettify(lang-julia){{
plt = plot(; margin=Plots.Measures.Length(:mm, 10.0)) # 1...
}}
~
いつのバージョンからかはわからんが(確認が面倒くさい),P...
#codeprettify(lang-julia){{
plt = plot(; margin=10*Plots.PlotMeasures.mm) # 10mm
}}
End:
*Plots メモ [#p2e2f2c3]
#contents
**Plots について [#occbadc0]
Julia には様々な図の作成方法があるらしい.~
その中で Plots は,他の描画ツールをバックエンドとして,Pl...
メリットは,同じコードでもバックエンドを切り替えるだけで...
バックエンドを切り替えてみて,見栄えの良い図をその都度選...
下記リンクにあるように,(ほぼ)同じ文構造で図を作成できる.
-[[GR バックエンド>https://docs.juliaplots.org/latest/gal...
-[[PyPlot バックエンド>https://docs.juliaplots.org/latest...
-[[PlotlyJS バックエンド>https://docs.juliaplots.org/late...
MATLAB や Python の matplotlib に近いので,これらに慣れて...
ただし,PyPlot というパッケージがあるので matplotlib 以外...
~
~
**図作成の基本 [#oe847565]
Plots の図の書き方は原則2種類ある.~
plot で始まり,seriestype (linetype) 引数でスタイルを指定...
#codeprettify(lang-julia){{
using Plots
}}
を宣言して,scatter は
#codeprettify(lang-julia){{
plot(x, y, seriestype=scatter) # or
scatter(x,y)
}}
contour は
#codeprettify(lang-julia){{
plot(X, Y, Z, seriestype=contour) # or
contour(X,Y,Z)
}}
という感じ.バックエンドによってはできないスタイルもある.~
(呼び出しているだけであり,バックエンド本体の範疇を超える...
contour や surface 系の平面図については,MATLAB や matplo...
X, Y がベクトル(Vector, Array{T,1})でなければならない点に...
~
~
**体裁の整え方 [#z525e4e4]
#codeprettify(lang-julia){{
plot(; color=(:plasma), xlims=(0,1), ylims=(0,1), label="...
}}
のように plot のキーワード引数を使う方法と
#codeprettify(lang-julia){{
plot(...)
xlims!(0,1)
ylims!(0,1)
}}
または
#codeprettify(lang-julia){{
plt = plot(...)
plt = plot!(plt, xlims=(0,1), ylims=(0,1))
}}
のように後付けする方法がある.~
[[Attributes>http://docs.juliaplots.org/latest/attributes...
引数の型が Tuple か普通の Array かよくわからなくなった時...
~
~
**線やマーカーの色の取得 [#gc85472d]
線やマーカで使う(:auto で決まる)色を予め取得する場合.~
#codeprettify(lang-julia){{
c = palette(:auto)
}}
のようにする.~
~
~
**マーカーの設定 [#ge62e820]
キーワード引数は marker (エイリアスの m や mark も可)で,...
#codeprettify(lang-julia){{
scatter!(plt, x, y; marker=(:magenta, 0.8, Plots.stroke(1...
}}
[[Attributes>https://docs.juliaplots.org/latest/attribute...
~
~
**複数の図を1枚に表示 [#s41fa3df]
別々に作成した Plots.Plot 型の図を subplot のように使う.~
事前にレイアウトを決定する必要がなく,後で決められるのが...
pltA と pltB を並べる時は
#codeprettify(lang-julia){{
# pltA::T, pltB::T where T <: Plots.Plot を 2x1 (縦 x 横)...
plts = plot(pltA, pltB, layout=(2,1), size=(600,600))
}}
結合した図の大きさはキーワード引数 size を使って調整する.~
この結合を複数回行うことで,(n x m) に限らず任意の配置で...
ただし,バックエンドによっては対応していなかったり図がぐ...
~
~
**(GR) リモートサーバーでの出力エラー [#c14aa673]
ssh で入っているコンピュータに対して処理をしたい時に,表...
画像ファイルとして出力しようにも,このエラーによって阻ま...
#codeprettify(lang-julia){{
ENV["GKSwstype"]="nul"
}}
または
#codeprettify(lang-julia){{
ENV["GKSwstype"]=100
}}
とすると,エラー回避できる.
~
~
**余白(margin)の設定 [#r1c6f0d5]
キーワード引数 margin を使う.~
4つのそれぞれの margin を指定したければ,bottom_margin, t...
#codeprettify(lang-julia){{
plt = plot(; margin=Plots.Measures.Length(:mm, 10.0)) # 1...
}}
~
いつのバージョンからかはわからんが(確認が面倒くさい),P...
#codeprettify(lang-julia){{
plt = plot(; margin=10*Plots.PlotMeasures.mm) # 10mm
}}
Page:
Edit with a page name which already exists