,

Histogram plotting using Gnuplot

Gnuplot to plot histograms
To plot histograms using Gnuplot, please follow the steps given below. Gnuplot supports various techniques on historgrams like

  • Clustered
  • RowStacked
  • ColumnStacked
  • etc.
Use the following video to watch the complete steps and description

Steps for Gnuplot


Part 1 - Gnuplot (Already In my youtube Channel)
Part 2 - Histogram

Step 1: Create a Data File
Air Quality Index for famous cities across the world.

#Filename is: aqi.data
Chennai 323 278 567
Turkey 890 765 456
Andorra 7 7 98
Palestine 70 67 56
Bulgaria 159 123 100
China 677 478 123
Netherlands 52 76 43

Step 2 : Write the GNU COde.

#filename: gnucode.txt
set terminal pdf
set output "aqi.pdf"
set title "Air Quality Index"
set style data histogram
set style fill solid
set style histogram clustered
plot for [COL=2:4] "aqi.data" using COL:xtic(1) title "AQI"

The following is the output in the pdf file that is generated within the same folder
gnuplot
Gnuplot histograms

Store both the above files in one folder

To run the above file,

Open the Terminal
$] gnuplot gnucode.txt

Data and Code in the Same File
In case if the plotting data and the source code for gnuplot is in the same file, then here is the steps

set terminal pdf
set output "aqi2.pdf"
set title "Air Quality Index"
set style data histogram
set style fill solid
set xtic rotate out
#set style histogram clustered
plot "-" using 2:xtic(1) title "AQI"
Delhi 100
Chennai 98
Mumbai 87
Pune 67
Madurai 17
e

This the following output
Gnuplot
Gnuplot

Thanks for watching my channel

Please subscribe and share it to your friends.

EngineeringClinic


0 comments:

Post a Comment