Difference between revisions of "Gnuplot/C2/Set-term-and-variations-in-output/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 20: Line 20:
 
|| '''Slide Number 3'''
 
|| '''Slide Number 3'''
 
'''Learning Objectives'''
 
'''Learning Objectives'''
|| In this tutorial we will learn about,
+
||
 
* '''ASCII output''' command
 
* '''ASCII output''' command
 
and
 
and
Line 54: Line 54:
 
|| Hover mouse next to '''term X11'''.
 
|| Hover mouse next to '''term X11'''.
 
|| Notice, the '''terminal''' type is shown here as '''x11'''.
 
|| Notice, the '''terminal''' type is shown here as '''x11'''.
 +
 
For some users '''qt''' or '''wxt terminal''' will be the default '''terminal'''.
 
For some users '''qt''' or '''wxt terminal''' will be the default '''terminal'''.
  
Line 59: Line 60:
 
|| Cursor on the '''terminal'''.
 
|| Cursor on the '''terminal'''.
 
|| '''Gnuplot''' supports several types of terminals.
 
|| '''Gnuplot''' supports several types of terminals.
 +
 
Let’s open the details about '''terminal''' types using the help documentation.
 
Let’s open the details about '''terminal''' types using the help documentation.
  
Line 71: Line 73:
 
|-
 
|-
 
|| Hover mouse over '''set terminal'''.
 
|| Hover mouse over '''set terminal'''.
| The help documentation for the '''terminal''' opens.
+
||The help documentation for the '''terminal''' opens.
  
 
|-
 
|-
||  
+
|| Point to the '''set terminal''' command.
 
|| The '''set terminal''' command allows to set, the type of output to be generated.
 
|| The '''set terminal''' command allows to set, the type of output to be generated.
  
Line 80: Line 82:
 
|| Hover mouse over '''set output'''.
 
|| Hover mouse over '''set output'''.
 
|| This is commonly used together with '''set output''' command.
 
|| This is commonly used together with '''set output''' command.
 +
 
This directs the output to a file or a device.
 
This directs the output to a file or a device.
  
Line 87: Line 90:
 
Press '''Enter''' again.
 
Press '''Enter''' again.
 
|| The prompt reads as, '''Press return for more'''.
 
|| The prompt reads as, '''Press return for more'''.
 +
 
So, press '''Enter'''.
 
So, press '''Enter'''.
 +
 
Press '''Enter''' again, till you notice the '''terminal''' list on the screen.  
 
Press '''Enter''' again, till you notice the '''terminal''' list on the screen.  
  
Line 102: Line 107:
 
|| Hover mouse over '''postscript, pdf, svg'''.
 
|| Hover mouse over '''postscript, pdf, svg'''.
 
|| '''Postscript''' and '''svg''' terminals direct output to a file in their respective formats.
 
|| '''Postscript''' and '''svg''' terminals direct output to a file in their respective formats.
 +
 
The output can be saved and edited by the user.  
 
The output can be saved and edited by the user.  
  
Line 109: Line 115:
  
 
|-
 
|-
||  
+
|| Cursor on the terminal.
 
|| Next, we will explore the options for '''postscript terminal'''.
 
|| Next, we will explore the options for '''postscript terminal'''.
  
Line 122: Line 128:
 
|-
 
|-
 
|| Type '''postscript''' and press '''Enter'''.
 
|| Type '''postscript''' and press '''Enter'''.
| I will type '''postscript''' in the subtopic of set term prompt and press '''Enter'''.
+
|| I will type '''postscript''' in the subtopic of set term prompt and press '''Enter'''.
  
 
|-
 
|-
Line 168: Line 174:
 
|-
 
|-
 
|| Go to the '''terminal'''.
 
|| Go to the '''terminal'''.
| Go to the '''terminal'''.
+
|| Go to the '''terminal'''.
  
 
|-
 
|-
Line 177: Line 183:
 
|| Type '''set term postscript landscape''' and press '''Enter '''.
 
|| Type '''set term postscript landscape''' and press '''Enter '''.
 
|| Type '''set space term space postscript''' '''space landscape'''.
 
|| Type '''set space term space postscript''' '''space landscape'''.
 +
 
This sets a '''postscript''' capable '''terminal''' in '''landscape''' orientation.
 
This sets a '''postscript''' capable '''terminal''' in '''landscape''' orientation.
  
Line 188: Line 195:
 
|| Type '''plot sin(x)''' and press '''Enter'''.
 
|| Type '''plot sin(x)''' and press '''Enter'''.
 
|| Enter command '''plot sin(x)''' to generate output to the file '''sinx.ps'''.
 
|| Enter command '''plot sin(x)''' to generate output to the file '''sinx.ps'''.
 +
 
The output files are generated in the working directory.
 
The output files are generated in the working directory.
  
Line 199: Line 207:
 
|| Let's check the path of '''gnuplot'''.  
 
|| Let's check the path of '''gnuplot'''.  
 
Enter the command '''pwd'''.
 
Enter the command '''pwd'''.
 +
 
The path shown here is '''Desktop''' directory.
 
The path shown here is '''Desktop''' directory.
  
Line 222: Line 231:
 
and press '''Enter'''.
 
and press '''Enter'''.
 
|| For this, enter the command as shown here.
 
|| For this, enter the command as shown here.
 +
 
Type '''set space term space svg'''.  
 
Type '''set space term space svg'''.  
 +
 
I will continue to add more specifications on the same line.
 
I will continue to add more specifications on the same line.
  
Line 228: Line 239:
 
|| Hover mouse on the command at '''background “cyan” size 400,400''' on the screen.
 
|| Hover mouse on the command at '''background “cyan” size 400,400''' on the screen.
 
|| I will set a '''cyan''' background for the plot.
 
|| I will set a '''cyan''' background for the plot.
 +
 
I will also set the output image pixel size to be 400 by 400.
 
I will also set the output image pixel size to be 400 by 400.
 
`
 
`
Line 233: Line 245:
 
|| Type '''set output “sinx.svg”''' and press '''Enter'''.
 
|| Type '''set output “sinx.svg”''' and press '''Enter'''.
 
|| Now, specify a file name for the plot.  
 
|| Now, specify a file name for the plot.  
 +
 
Type the following command.
 
Type the following command.
 
'''set space output space in double quotes sinx dot svg'''.
 
'''set space output space in double quotes sinx dot svg'''.
Line 243: Line 256:
 
|| Hover mouse over the 3 column output.
 
|| Hover mouse over the 3 column output.
 
|| The output shows color name, corresponding '''hex code''' and the '''RGB code'''.
 
|| The output shows color name, corresponding '''hex code''' and the '''RGB code'''.
 +
 
You may use this command to know more about color codes for different colors.
 
You may use this command to know more about color codes for different colors.
  
Line 260: Line 274:
 
|| Double click to open the '''first.svg''' file.
 
|| Double click to open the '''first.svg''' file.
 
|| Open the '''sinx.svg''' file.
 
|| Open the '''sinx.svg''' file.
 +
 
View the square '''400''' by '''400''' '''pixel''' image of the graph.
 
View the square '''400''' by '''400''' '''pixel''' image of the graph.
 +
 
The '''background''' has cyan color as specified.
 
The '''background''' has cyan color as specified.
  
Line 271: Line 287:
 
and press '''Enter'''.
 
and press '''Enter'''.
 
|| We can save the '''terminal''' setting for future use.
 
|| We can save the '''terminal''' setting for future use.
 +
 
Type '''save''' space '''term''' space in double quotes '''svg dot term'''.
 
Type '''save''' space '''term''' space in double quotes '''svg dot term'''.
  
Line 292: Line 309:
 
|| Type '''set term pop''' and press '''Enter'''.
 
|| Type '''set term pop''' and press '''Enter'''.
 
|| To reset the terminal setting to the default state, type the following command.
 
|| To reset the terminal setting to the default state, type the following command.
 +
 
Enter the command, '''set space term space pop'''.
 
Enter the command, '''set space term space pop'''.
  
 
|-
 
|-
|| Curson in the terminal.
+
|| Cursor in the terminal.
 
|| The reset command does not reset the '''terminal''' settings.
 
|| The reset command does not reset the '''terminal''' settings.
  
Line 306: Line 324:
 
|| Type '''plot sin(x) '''.
 
|| Type '''plot sin(x) '''.
 
|| Enter the command '''plot space sinx''' with '''x''' in parenthesis.
 
|| Enter the command '''plot space sinx''' with '''x''' in parenthesis.
 +
 
Now, the plot is generated in the graphics window with the initial settings.
 
Now, the plot is generated in the graphics window with the initial settings.
  
Line 316: Line 335:
 
|| Type '''set term dumb''' and press '''Enter'''.
 
|| Type '''set term dumb''' and press '''Enter'''.
 
|| At the prompt, enter the command, '''set space term space dumb'''.  
 
|| At the prompt, enter the command, '''set space term space dumb'''.  
 +
 
'''ASCII''' code is uniform across all operating systems.  
 
'''ASCII''' code is uniform across all operating systems.  
 
Hence the files are portable across all operating systems.
 
Hence the files are portable across all operating systems.
Line 322: Line 342:
 
|| Enter command '''plot sin(x) '''.
 
|| Enter command '''plot sin(x) '''.
 
|| Enter the command '''plot space sin x''', with '''x''' in parenthesis.
 
|| Enter the command '''plot space sin x''', with '''x''' in parenthesis.
 +
 
This prints '''ASCII''' text art output results.
 
This prints '''ASCII''' text art output results.
  
Line 327: Line 348:
 
|| Show the '''ASCII''' output.
 
|| Show the '''ASCII''' output.
 
|| I will zoom out the sin(x) plot on the screen.
 
|| I will zoom out the sin(x) plot on the screen.
 +
 
The output, is seen on the '''terminal''' screen.
 
The output, is seen on the '''terminal''' screen.
 +
 
Notice the difference from the interactive '''terminal''' output.
 
Notice the difference from the interactive '''terminal''' output.
  

Revision as of 13:03, 29 November 2019

Visual Cue Narration
Slide Number 1

Title Slide

Welcome to the tutorial on Set Term and Variations in Output in gnuplot.
Slide Number 2

Learning Objectives

In this tutorial we will learn about,
  • Interactive terminal setting
  • Generating a plot for printing and sharing
  • Save the plot in postscript and svg image formats
  • Save and reset the terminal setting
Slide Number 3

Learning Objectives

  • ASCII output command

and

  • Plot sin(x)-x plot in ASCII format
Slide Number 4

System and Software Requirement

To record this tutorial, I am using
  • Debian Linux 9.3
  • gnuplot 5.2.6 and
  • gedit text editor 3.22
Slide Number 5

Pre-requisites https://spoken-tutorial.org/

To follow this tutorial,
  • Learner must be familiar with high school Mathematics.
  • For pre-requisite tutorials, please visit this site.
Press Ctrl+Alt+T.

Type cd Desktop and press Enter.

Open the terminal and change the working directory to Desktop.

Enter the command as seen on the screen.

Type gnuplot, and press Enter. Type gnuplot and press Enter to open gnuplot.
Hover mouse next to term X11. Notice, the terminal type is shown here as x11.

For some users qt or wxt terminal will be the default terminal.

Cursor on the terminal. Gnuplot supports several types of terminals.

Let’s open the details about terminal types using the help documentation.

Press Control+Shift+K. I will clear the screen.
Type help set term and press Enter . Enter the command help space set space term.
Hover mouse over set terminal. The help documentation for the terminal opens.
Point to the set terminal command. The set terminal command allows to set, the type of output to be generated.
Hover mouse over set output. This is commonly used together with set output command.

This directs the output to a file or a device.

Hover mouse over Press return for more.

Press Enter. Press Enter again.

The prompt reads as, Press return for more.

So, press Enter.

Press Enter again, till you notice the terminal list on the screen.

Hover mouse on the terminals shown on the screen. Nearly 40 types of terminals are supported by gnuplot.
Hover mouse over x11, xterm. For example, x11 and xterm are interactive terminals.

They help to plot graphs on the screen.

Hover mouse over postscript, pdf, svg. Postscript and svg terminals direct output to a file in their respective formats.

The output can be saved and edited by the user.

Point mouse to terminals available. These aid the user in printing and sharing of graphs.
Cursor on the terminal. Next, we will explore the options for postscript terminal.
Hover mouse near subtopic. The prompt is at subtopic of set term indicating the user to enter a subtopic.
Cursor on the terminal. Let's access help files for postscript file generation.
Type postscript and press Enter. I will type postscript in the subtopic of set term prompt and press Enter.
Hover mouse over syntax seen on screen. Detailed syntax options for generating postscript file is shown on the screen.
Hover mouse over landscape | portrait . The orientation can be set to landscape or portrait.
Hover mouse below on color, duplex and size. Color, duplex option and size of the plot and other details can also be set here.
Press Enter. Press Enter as seen at the prompt.
Show on screen help setting. More details about the settings appear on the screen.
You may pause the video and explore more about the command options.
Press Ctrl+C . I will press Ctrl C to exit the help details.
Press Control+Shift+K I will clear the terminal.
Type plot sin(x) and press Enter. Enter the command plot space sin x with x in parenthesis.
Show the graph on the screen.

Close the graphics window.

Sin x versus x graph appears on the screen.

Close the graphics window.

Go to the terminal. Go to the terminal.
Cursor on the terminal. Next, let's make a postscript file for the sin x plot.
Type set term postscript landscape and press Enter . Type set space term space postscript space landscape.

This sets a postscript capable terminal in landscape orientation.

Type set output “sinx.ps” and press Enter. Next, type set space output space in double quotes sinx dot ps.
Hover mouse next to the command. This sets output in the user specified filename sinx dot ps.
Type plot sin(x) and press Enter. Enter command plot sin(x) to generate output to the file sinx.ps.

The output files are generated in the working directory.

Press Control+Shift+K I will clear the terminal.
Type pwd and press Enter.

Hover mouse over the result.

Let's check the path of gnuplot.

Enter the command pwd.

The path shown here is Desktop directory.

Go to Desktop and show the sinx.ps file. Go to Desktop and notice the newly created file.
Open sinx.ps file. Double click on the icon to open and view the file.
Close sinx.ps and go back to gnuplot. We will close the output file and go back to gnuplot.
Press Control+Shift+K . I will clear the screen.

Let's save the output to a svg image file.

Type set term svg background “cyan” size 400,400

and press Enter.

For this, enter the command as shown here.

Type set space term space svg.

I will continue to add more specifications on the same line.

Hover mouse on the command at background “cyan” size 400,400 on the screen. I will set a cyan background for the plot.

I will also set the output image pixel size to be 400 by 400. `

Type set output “sinx.svg” and press Enter. Now, specify a file name for the plot.

Type the following command. set space output space in double quotes sinx dot svg.

Type show palette colornames and press Enter. The command, show palette colornames returns the color codes in gnuplot.
Hover mouse over the 3 column output. The output shows color name, corresponding hex code and the RGB code.

You may use this command to know more about color codes for different colors.

Press Ctrl+Alt+K. I will clear the screen.
Type plot sin(x) and press Enter. Enter the command, plot sin(x) to generate the svg image.
Go to Desktop and show sinx.svg file icon. Next, go to Desktop and notice the sinx.svg file that is generated.
Double click to open the first.svg file. Open the sinx.svg file.

View the square 400 by 400 pixel image of the graph.

The background has cyan color as specified.

Close the image file and go back to gnuplot. We will close the output file and go back to gnuplot.
Type save term “svg.term”

and press Enter.

We can save the terminal setting for future use.

Type save space term space in double quotes svg dot term.

Go to Desktop and show svg.term file icon. Let us go to the Desktop and notice the newly created svg dot term file.
Open svg.term file in text eidtor. I will open it in a text editor.
Show the opened svg.term file. This file will have the details of the color and size as we entered.
Close the image file and go back to gnuplot. We will close the output file and go back to gnuplot.
Type set term pop and press Enter. To reset the terminal setting to the default state, type the following command.

Enter the command, set space term space pop.

Cursor in the terminal. The reset command does not reset the terminal settings.
Press Control+Shift+K. Now, we are back on the interactive terminal.

I will clear the screen.

Type plot sin(x) . Enter the command plot space sinx with x in parenthesis.

Now, the plot is generated in the graphics window with the initial settings.

Close graphics window. Close the graphics window.

ASCII output can also be generated in gnuplot.

Type set term dumb and press Enter. At the prompt, enter the command, set space term space dumb.

ASCII code is uniform across all operating systems. Hence the files are portable across all operating systems.

Enter command plot sin(x) . Enter the command plot space sin x, with x in parenthesis.

This prints ASCII text art output results.

Show the ASCII output. I will zoom out the sin(x) plot on the screen.

The output, is seen on the terminal screen.

Notice the difference from the interactive terminal output.

Type q and press Enter . Enter the command q or quit to quit gnuplot.
Slide Number 6

Summary

Now let’s summarize. In this tutorial, we,
  • Learned about terminal types
  • Saved the output to different file types
  • Created customized outputs
  • Saved the terminal setting
  • Reset the terminal setting
  • Learned about dumb terminal command

and

  • Generated an ASCII output
Slide Number 7

Assignment 1

For assignment, plot the following functions,
  • Save cos(x) versus x plot in svg file format.
  • Change the background color and size in the output file.
Slide Number 8

Assignment 2

For assignment, plot the following functions,
  • Set terminal to dumb.
  • Generate cos(x) versus x plot in ASCII format.
Show glimpse of the completed assignment. The completed assignment look similar to this.
Slide Number 9

Spoken Tutorial Project

This video summarises the Spoken Tutorial Project.

Please download and watch it.

Slide Number 10

Spoken Tutorial workshops

We conduct workshops and give certificates.

Please write to us.

Slide Number 11

Forum for specific questions

Please Post your timed queries in the forum.
Slide Number 12

Acknowledgement

Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
This is Rani from IIT, Bombay. Thank you for joining.

Contributors and Content Editors

Madhurig, Ranipv076, Snehalathak