目的
これをこうしたい。
| 変更前 | 変更後 |
|---|---|
![]() |
![]() |
方法
@sprintf と plotのオプションであるformatterを用いる。
using Plots
using Printf: @sprintf
θ = range(-π,π,100)
fig = plot(
xlabel = "θ",
ylabel = "sinθ",
xformatter = x -> @sprintf("%.1fπ",x/π),
yformatter = y -> @sprintf("%.2f",y),
)
plot!(fig,
θ,
sin.(θ),
label = :none,
)
まとめ
xticksなどで指定する方法もありますが、formatterも便利そうなので、ぜひいろいろ情報提供いただきたいです。
あと、plotの引数は縦書きで、Matplotlibのようにfigを作成してから追記していく派です。

