Skip to content

Instantly share code, notes, and snippets.

@hindol
Created August 30, 2013 10:07
Show Gist options
  • Save hindol/6388344 to your computer and use it in GitHub Desktop.
Save hindol/6388344 to your computer and use it in GitHub Desktop.
Example on how to use GNUPlot to output high quality graphs
#!/usr/bin/env bash
INPUT_DIR="../50_5_5"
OUTPUT_DIR=".."
PARAMETERS=( "like-mindedness" "modularity" )
LABELS=( "Like-mindedness" "Modularity (Q)" )
for i in ${!PARAMETERS[*]}; do
gnuplot <<- EOF
set terminal postscript eps enhanced color solid
set output '${OUTPUT_DIR}/${PARAMETERS[$i]}.eps'
set style line 1 lt 1 lw 2 lc 1
set style line 2 lt 1 lw 2 lc 2
set style line 5 lt 0 lw 2 lc 2
set style line 3 lt 1 lw 2 lc 3
set style line 6 lt 0 lw 2 lc 3
set style line 4 lt 1 lw 2 lc 4
set style line 7 lt 0 lw 2 lc 4
set key center right
set title '${LABELS[$i]} vs. |C|'
set xlabel 'Number of communities (|C|)'
set ylabel '${LABELS[$i]}'
set grid xtics
set grid ytics
plot '${INPUT_DIR}/${PARAMETERS[$i]}.betweenness' w l ls 1 title 'GN', \
'${INPUT_DIR}/${PARAMETERS[$i]}.seen.single-linkage' w l ls 2 title 'SS', \
'${INPUT_DIR}/${PARAMETERS[$i]}.seen.average-linkage' w l ls 3 title 'AS', \
'${INPUT_DIR}/${PARAMETERS[$i]}.seen.complete-linkage' w l ls 4 title 'CS', \
'${INPUT_DIR}/${PARAMETERS[$i]}.rating.single-linkage' w l ls 5 title 'SR', \
'${INPUT_DIR}/${PARAMETERS[$i]}.rating.average-linkage' w l ls 6 title 'AR', \
'${INPUT_DIR}/${PARAMETERS[$i]}.rating.complete-linkage' w l ls 7 title 'CR'
EOF
done
PREFIXES=( 10 20 30 40 50 58 100 128 200 300 400 500 1000 2000 3000 4000 5000 )
PARAMETERS=( clu den sep )
SUFFIXES=( clustering-coefficient density separability )
LABELS=( Clustering-coefficient Density Separability )
for PREFIX in "${PREFIXES[@]}"; do
for i in ${!PARAMETERS[*]}; do
gnuplot <<- EOF
set terminal postscript eps enhanced color solid
set output '${OUTPUT_DIR}/${SUFFIXES[$i]}_${PREFIX}.eps'
set style line 1 lt 1 lw 2 lc 1
set style line 2 lt 1 lw 2 lc 2
set style line 5 lt 0 lw 2 lc 2
set style line 3 lt 1 lw 2 lc 3
set style line 6 lt 0 lw 2 lc 3
set style line 4 lt 1 lw 2 lc 4
set style line 7 lt 0 lw 2 lc 4
set style line 8 lt 1 lw 2 lc 5
set title 'Cumulative Average of ${LABELS[$i]} vs. k'
set xlabel 'k'
set ylabel 'Average ${SUFFIXES[$i]} of top k communities'
set grid xtics
set grid ytics
set xrange [0:${PREFIX}]
unset border
plot '${INPUT_DIR}/${PREFIX}_communities.betweenness.${PARAMETERS[$i]}.avg' w l ls 1title 'GN', \
'${INPUT_DIR}/${PREFIX}_communities.seen.single-linkage.${PARAMETERS[$i]}.avg' w l ls 2 title 'SS', \
'${INPUT_DIR}/${PREFIX}_communities.seen.average-linkage.${PARAMETERS[$i]}.avg' w l ls 3 title 'AS', \
'${INPUT_DIR}/${PREFIX}_communities.seen.complete-linkage.${PARAMETERS[$i]}.avg' w l ls 4 title 'CS', \
'${INPUT_DIR}/${PREFIX}_communities.rating.single-linkage.${PARAMETERS[$i]}.avg' w l ls 5 title 'SR', \
'${INPUT_DIR}/${PREFIX}_communities.rating.average-linkage.${PARAMETERS[$i]}.avg' w l ls 6 title 'AR', \
'${INPUT_DIR}/${PREFIX}_communities.rating.complete-linkage.${PARAMETERS[$i]}.avg' w l ls 7 title 'CR', \
'${INPUT_DIR}/${PREFIX}_communities.modularity.${PARAMETERS[$i]}.avg' w l ls 8 title 'MM'
EOF
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment