Getting started with Plots.jl

Introduction to Data Visualization with Julia

Gustavo Vieira Suñe

Data Analyst

Plots.jl

Plots.jl logo

Introduction to Data Visualization with Julia

Installing and importing Plots.jl

  • Installation
using Pkg

Pkg.add("Plots")
  • Import
using Plots
Introduction to Data Visualization with Julia

Our first Julia plot

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, )

A line plot depicting the price fluctuations of a fund over time, with a noticeable upward trend except for a dip in March 2020.

Introduction to Data Visualization with Julia

From lines to points

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, )

A simple scatter plot showing the relationship between daily opening and closing prices. The graph displays a positive correlation between the two variables.

Introduction to Data Visualization with Julia

Adding title and axis labels

# 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)", )

A simple scatter plot showing the relationship between daily opening and closing prices. The graph displays a positive correlation between the two variables.

Introduction to Data Visualization with Julia

Cheat Sheet

  • Line plots

    • Trends over time
      plot(x, y)
      
  • Scatter plots

    • Relationships
      scatter(x, y)
      
  • Axis labels and titles
    • Easier to interpret plot
      title="My title", xlabel="My x-label", ylabel="My y-label"
      
Introduction to Data Visualization with Julia

Let's practice!

Introduction to Data Visualization with Julia

Preparing Video For Download...