Skip to content

sjsu-interconnect/intro-to-gnuplot

Repository files navigation

Visualization

Installation

Ubuntu

sudo apt install gnuplot

Reference

Official demo

First Plot

$ gnuplot initiates the gnuplot window.

gnuplot> plot sin(x)

Scripting

You can create a script file including multiple gnuplot commands, instead of using the interactive command window. The script file is a simple text file. (A typical extension is .plt)

When you execute the script file, use the load command.

gnuplot> load 'script.plt'

Basic Plot Settings

Note: You can write the following in the script file.

gnuplot> set term dumb
gnuplot> set term pngcairo
gnuplot> set out "filename.png"
gnuplot> set xr[0:1]    # 0<=x<=1
gnuplot> set yr[-1:1]   # -1<=y<=1
gnuplot> set size 0.6, 0.4    # 0.6*(width) and 0.4*(height)
gnuplot> set xlabel "time"
gnuplot> set ylabel "volume"
gnuplot> set xtics 2      # Control of the major (labelled) tics on the x axis
gnuplot> set mxtics 5     # Minor tic marks along the x axis

Examples

  • Scatter plot
  • Histogram
  • Box Plot

Case Study: Population

Using the world_population.csv data set, plot the population in a few countries in 1980, 1990, 2010, 2020, and 2022.

For a line plot, you can use a command like this:

plot 'population-data.dat' using 1:2 w lp lw 2 title "NAM"

You can clean up and reshape the dataset using AWK. (The cleaned data set is called population-data.dat.)

Here is a plot example.

p-eg

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published