開始使用 Plots.jl

Julia 資料視覺化入門

Gustavo Vieira Suñe

Data Analyst

Plots.jl

Plots.jl 標誌

Julia 資料視覺化入門

安裝與載入 Plots.jl

  • 安裝
using Pkg

Pkg.add("Plots")
  • 載入
using Plots
Julia 資料視覺化入門

第一個 Julia 圖表

using CSV, DataFrames
using Plots

# Load dataset fund = DataFrame(CSV.File("fund.csv"))
# Plot prices over time plot( # Values in x-axis fund.price_date, # Values in y-axis fund.open, )

一張折線圖,呈現基金價格隨時間波動,整體向上,但在 2020 年 3 月有明顯下跌。

Julia 資料視覺化入門

從折線到散點

using CSV, DataFrames
using Plots

# Load dataset
fund = DataFrame(CSV.File("fund.csv"))

# Plot open and close prices scatter( # Values in x-axis fund.open, # Values in x-axis fund.close, )

一張散佈圖顯示每日開盤價與收盤價的關係,兩者呈現正相關。

Julia 資料視覺化入門

加入標題與座標軸標籤

# Plot open and close prices
scatter(
    fund.open,
    fund.close,

# Add title title="Intraday Price Movement",
# Add axis labels xlabel="Opening Price (USD)", ylabel="Closing Price (USD)", )

一張散佈圖顯示每日開盤價與收盤價的關係,兩者呈現正相關。

Julia 資料視覺化入門

速查表

  • 折線圖

    • 時間趨勢
      plot(x, y)
      
  • 散佈圖

    • 變數關係
      scatter(x, y)
      
  • 座標軸與標題
    • 圖表更易讀
      title="My title", xlabel="My x-label", ylabel="My y-label"
      
Julia 資料視覺化入門

一起來練習吧!

Julia 資料視覺化入門

Preparing Video For Download...