Skip to content

Instantly share code, notes, and snippets.

@mc3k
Created January 1, 2025 01:20
Show Gist options
  • Save mc3k/80941f447486454730dd4ac7079d5d26 to your computer and use it in GitHub Desktop.
Save mc3k/80941f447486454730dd4ac7079d5d26 to your computer and use it in GitHub Desktop.
Plot the elevation profile of GPX profile using GNUPlot and GPXPlot3.py
#!/bin/bash
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
cd "$SCRIPTPATH"
python3 gpxplot3.py -y elevation -x distance $1 > gpx.dat & pid1=$!
wait $pid1
echo "
set output '$1.png'
set title '$2'
set ylabel 'Elevation (m)'
set xlabel 'Distance (km)'
set ytics 200
set grid
set style fill transparent solid 0.50
set style fill border 1
stats 'gpx.dat' u 3:2 nooutput
set xrange [STATS_min_x:STATS_max_x]
set yrange [STATS_min_y:]
set terminal pngcairo size (STATS_max_x*10+100),(((STATS_max_y-STATS_min_y)/5)+50) font ',10'
set label 1 gprintf('%.0f m',STATS_max_y) at STATS_pos_max_y, STATS_max_y offset 1,0.75 textcolor linetype 3
set label 2 gprintf('%.0f m',STATS_min_y) at STATS_pos_min_y, STATS_min_y offset 1,-0.75 textcolor lt 3
plot 'gpx.dat' using 3:2 with filledcurves x1 notitle lc 3 \
,'gpx.dat' using 3:2 with lines notitle lc 3 lw 2 \
" | gnuplot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment