# Open SourceMolecular Dynamics

### Site Tools

exercises:2014_uzh_molsim:gnuplot

# Differences

This shows you the differences between two versions of the page.

 exercises:2014_uzh_molsim:gnuplot [2014/04/29 13:24]talirz exercises:2014_uzh_molsim:gnuplot [2014/05/06 22:18]talirz Added hint about scripting Both sides previous revision Previous revision 2014/05/06 22:18 talirz Added hint about scripting2014/05/01 07:54 talirz 2014/04/29 13:24 talirz 2014/04/24 17:12 talirz 2014/04/24 17:12 talirz 2014/04/24 17:11 talirz 2014/04/24 17:10 talirz 2014/04/24 17:09 talirz 2014/04/24 16:39 talirz 2014/04/24 16:38 talirz created Next revision Previous revision 2014/05/06 22:18 talirz Added hint about scripting2014/05/01 07:54 talirz 2014/04/29 13:24 talirz 2014/04/24 17:12 talirz 2014/04/24 17:12 talirz 2014/04/24 17:11 talirz 2014/04/24 17:10 talirz 2014/04/24 17:09 talirz 2014/04/24 16:39 talirz 2014/04/24 16:38 talirz created Line 13: Line 13: plot '​spectrum.ener'​ using 1:4            # plot column 1 as x and column 4 as y plot '​spectrum.ener'​ using 1:4            # plot column 1 as x and column 4 as y replot '​spectrum.ener'​ using 1:($3+$5) title 'Total energy'​ replot '​spectrum.ener'​ using 1:($3+$5) title 'Total energy'​ - set ylabel ​"time steps" + set xlabel ​"time steps" set xrange [0:10] set xrange [0:10] replot ​                                    # redo the plot with current settings replot ​                                    # redo the plot with current settings Line 42: Line 42: - Finally, we want to use Gnuplot's fitting functionality. + Gnuplot ​is not just a plotting utility, it can also perform fits. Say, we have a data set ''​data.dat'',​ which contains $x$ in the first column and some computed $f(x)$ in the second column. Say, we have a data set ''​data.dat'',​ which contains $x$ in the first column and some computed $f(x)$ in the second column. We want to fit a function $f(x)=ax^2$ to this data set. In Gnuplot, this would be achieved by: We want to fit a function $f(x)=ax^2$ to this data set. In Gnuplot, this would be achieved by: Line 60: Line 60: ​ + Finally, once you have figured out which commands you need to create the plot you want, it is a good idea to write these commands to a file, say ''​script.gp''​. This has the advantage that gnuplot can re-create your graph in an instant. On the bash terminal type: + + gnuplot script.gp ​  # let gnuplot perform the commands in '​script.gp'​ + gnuplot ​            # alternative:​ start gnuplot + load '​script.gp' ​   #              and load script from within gnuplot + ​ + This makes it very quick and easy to change details in the plot at a later point in time. + Proficient gnuplot users will often start by writing the file, run it through gnuplot and then adjust the remaining details.