You can easily use gnuplot commands within an interactive shell, on in a shell script:
echo 'set term pngcairo; set output "file.png"; plot x' | gnuplot
You could also put your commands in file.gnuplot and then execute
gnuplot file.gnuplot
from within your shell script or interactive shell. If instead of writing to file you just want the graph to pop up using the default gnuplot terminal, you can add -persist:
echo 'plot x' | gnuplot -persist
You can also use shell commands inside a gnuplot script or gnuplot interactive session via a system() call, but that's a separate topic.