Skip to content

Instantly share code, notes, and snippets.

@hernamesbarbara
Last active July 1, 2025 14:22
Show Gist options
  • Save hernamesbarbara/ca4d17696a4c953fc3e05191833fe22c to your computer and use it in GitHub Desktop.
Save hernamesbarbara/ca4d17696a4c953fc3e05191833fe22c to your computer and use it in GitHub Desktop.

Use gnuplot to plot data in a csv file


gnuplot -p -c csv-plot.gp data.csv

#!/usr/bin/env gnuplot
# csv-plot.gp
# accept filename as input
filename = ARG1
# ----------------------
# Example data.csv file:
# timepoint,measure
# 2024-01-06,4834
# 2024-01-08,4845
# 2024-01-18,4857
# 2024-01-25,4874
# 2024-01-29,4880
# 2024-02-05,4897
# 2024-02-07,4905
# 2024-02-16,4927
# 2024-02-20,4939
# ----------------------
set datafile separator comma
set key bottom right
set xdata time
set timefmt "%Y-%m-%d"
set format x "%Y-%m"
set xtics rotate by -45
set yrange [0:*]
set grid
set title "My Measure Over Time"
set xlabel "Date"
set ylabel "My Measure"
set key autotitle columnheader
plot filename using 1:2 with linespoints lw 2 lc rgb "blue"
timepoint measure
2024-01-06 4834
2024-01-08 4845
2024-01-18 4857
2024-01-25 4874
2024-01-29 4880
2024-02-05 4897
2024-02-07 4905
2024-02-16 4927
2024-02-20 4939
2024-02-29 4953
2024-03-08 4975
2024-03-13 4994
2024-03-19 5007
2024-03-21 5015
2024-04-01 5033
2024-04-05 5049
2024-04-19 5071
2024-05-03 5101
2024-05-15 5139
2024-10-13 5506
2024-10-14 5512
2024-10-16 5528
2024-10-21 5545
2024-10-31 5565
2024-11-02 5574
2024-11-05 5585
2024-11-09 5593
2024-11-12 5602
2024-11-18 5612
2024-11-19 5620
2024-11-25 5635
2024-12-09 5666
2024-12-11 5679
2024-12-13 5683
2024-12-17 5694
2024-12-22 5700
2024-12-24 5704
2024-12-26 5706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment