• Home
  • Downloads
  • Contact Us
  • Report Broken Link
Friday, May 9, 2025
  • Login
lessons4you.info
  • Videos
  • Downloads
  • Help
    • Contact Us
    • Report Broken Link
No Result
View All Result
  • Videos
  • Downloads
  • Help
    • Contact Us
    • Report Broken Link
No Result
View All Result
Lessons4you.info
No Result
View All Result

How to Configure Mac Terminal to have Color Output

How to Update Galaxy Tab 7.7 P6800 with Android 4.1.2 DXMD3 Jelly Bean Official Firmware

BASH: Plot graph with one line command using gnuplot

by
December 11, 2021
in Uncategorized
Reading Time: 2 mins read
A A
Share on FacebookShare on Twitter

This is for a quick visual inspection of your job data output as XY plot. The XY data containing is read from the file data_input.dat

1
2
3
4
5
6
7
 
1.00    0.00000
2.00    0.74103
3.00    0.79751
..     ....
..     ....
 

1
2
3
4
 
$ gnuplot
> plot "data_input.dat"
 

Now a scatter plot will pop up as a window. If you are logged into remote session with ssh, make sure you have forwarded the X. i.e. logged in with -X flag

1
2
3
 
$ ssh -X yourhost
 

Change it to line plot by adding ‘with lines’

1
2
3
4
 
$ gnuplot
> plot "data_input.dat" with lines
 

Now for more advanced options:
1. To save the plot as png image, add set terminal png, set output “plot.png”

1
2
3
4
5
 
set terminal png
set output "plot.png"
plot "data_input.dat" with lines
 

Now the plot will be saved as ‘plot.png’ into working directory. You can open the image from terminal using eog (eye of gnome)

1
2
3
 
$ eog plot.png
 

2. To label the X and Y and plot grid, add set ylabel “RMS”, set xlabel “Time” and set grid

1
2
3
4
5
6
7
8
 
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" with lines
 

3. If you want to plot 1st and 5th column in your data_input.dat, add ‘using 1:5’ in plot command

1
2
3
4
5
6
7
8
 
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:5 with lines
 

4. To plot two data series in the same plot and label each line, add next series after a comma

1
2
3
4
5
6
7
8
 
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:2 with lines title 'data-1', "data_input.dat" using 1:5 with lines title 'data-5'
 

To plot many series, it’s convenient to use the line continuation character, “\” .

1
2
3
4
5
6
7
8
9
10
 
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:2 with lines title 'data-1', \
"data_input.dat" using 1:3 with lines title 'data-3' \
"data_input.dat" using 1:5 with lines title 'data-5' \
 

5. Running it from a script, Put all these commands into a script and run if you have to run them several times

1
2
3
4
5
6
7
8
9
10
11
12
 
#!/usr/bin/gnuplot
reset
set terminal png
set output "plot.png"
set ylabel "RMS"
set xlabel "Time"
set grid
plot "data_input.dat" using 1:2 with lines title 'data-1', \
"data_input.dat" using 1:3 with lines title 'data-3' \
"data_input.dat" using 1:5 with lines title 'data-5' \
 

matplotlib is another even better option for advanced graph creation
More examples:
1. Gnuplot 4.2 Tutorial
2. Plot your graphs with command line gnuplot
3. Data visualization tools for Linux

Tags: BashGnuplotPlot
Previous Post

How to Configure Mac Terminal to have Color Output

Next Post

How to Update Galaxy Tab 7.7 P6800 with Android 4.1.2 DXMD3 Jelly Bean Official Firmware

Related Posts

How To Install The TWRP Recovery on Xiaomi Redmi 1s
Uncategorized

How To Install The TWRP Recovery on Xiaomi Redmi 1s

May 14, 2022
MIUI Collection Of Gapps (2.3.x – 5.0.x)
Uncategorized

MIUI Collection Of Gapps (2.3.x – 5.0.x)

May 14, 2022
Download Android 5.1.x Lollipop PA Gapps
Uncategorized

Download Android 5.1.x Lollipop PA Gapps

May 15, 2022
Download gapps for Android 5.1 Lollipop Cyanogemod 12.1
Uncategorized

Download gapps for Android 5.1 Lollipop Cyanogemod 12.1

May 14, 2022
Reddit AMA with OxygenOS Team OnePlus
Uncategorized

Reddit AMA with OxygenOS Team OnePlus

May 14, 2022
How to Remove Adobe Updater from OS X Menu Bar?
Uncategorized

How to Remove Adobe Updater from OS X Menu Bar?

July 19, 2023
Next Post

How to Update Galaxy Tab 7.7 P6800 with Android 4.1.2 DXMD3 Jelly Bean Official Firmware

  • Home
  • Downloads
  • Contact Us
  • Report Broken Link

© 2022 lessons4you.info

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Videos
  • Downloads
  • Help
    • Contact Us
    • Report Broken Link

© 2022 lessons4you.info