search
HomeDatabaseMysql Tutorialgnuplot 入门教程 2

gnuplot 入门教程 2

Jun 07, 2016 pm 03:39 PM
gnuplotthingGetting Started Tutorial

几年前写的一篇短文,今天找东西时翻出来了,感觉写的还是比较实用的。放在这里供有需要的人参考吧。 3D 绘图 例11: splot [-pi:pi] [-pi:pi] sin(x)*cos(y) 产生图 2 结果 --- 以纵横各 10 条线组成的网画出 sin(x)*cos(y) 的图形。 图 3Plottingsin(x)*co

几年前写的一篇短文,今天找东西时翻出来了,感觉写的还是比较实用的。放在这里供有需要的人参考吧。

3D绘图

例 11:

splot [-pi:pi] [-pi:pi] sin(x)*cos(y)

产生图 2结果 --- 以纵横各 10 条线组成的网格画出 sin(x)*cos(y) 的图形。

gnuplot 入门教程 2

图 3 Plotting sin(x)*cos(y)

例 12 画等高线图:

set dgrid3d 100,100 #设置三维图表面的网格的数目
set contour    #设置画等高线
set cntrparam  levels  incremental -0.9,0.1,0.9   #设置等高线的疏密和范围,数据从   -0.2到0.2中间每隔0.01画一条线
unset surface  # 去掉上面的三维图形
set view 0,0
unset key
splot [-pi:pi] [-pi:pi] sin(x)*cos(y)

gnuplot 入门教程 2

例 13 画pm3d

set pm3d
set isosamples 50,50
splot x**2+y**2
gnuplot 入门教程 2
set view 0,0 #设置视角,(0,0)将投影到底面上去
unset ztics #把z轴上的数字给去掉
unset surface
splot x**2+y**2
reset
gnuplot 入门教程 2

输出文件

在启动时,您可能注意到终端类型设置为 X11gnuplot采用标准设计,可以在多个终端设备上绘图。这包括直接打印到多种打印机中,包括 EpsonHP 和 Imagen 打印机。它甚至可以在伪设备中绘图,如 postscript 和 png。这主要涉及生成输出文件,而不是可查看文件或打印输出。这是将您的图表包含在其他报表中的一种技巧。

例 14 设置输出和终端类型

set terminal png     # gnuplot recommends setting terminal before output
set output ‘output.png’  # The output filename
plot sin(x)

现在,文件 output.png 中有了您刚才绘制的图。

所有终端在能力上都不相同。其中的一些(如 LaTeX)可能不支持文本的旋转,所以如果您像我们前面那样设置 ylabel,在不同的终端中可能显示不一样。换句话说,您可以在 LaTeX 的特定终端中使用 LaTex 命令。例如,set ylabel $sin(\\\\theta)$(注意我们使用两个反斜杠产生一个 LaTex 所需的反斜杠 —— gnuplot 在将双引号中所括的字符串传送到终端驱动程序之前,先对其进行反斜杠处理)。现在,您可以使用 \\input{output.tex} 将输出文件包含在 LaTeX 文件中。要在 PostScript 终端中获得相同的结果,使用相应的 PostScript 命令:{/Symbol q}。在 enhanced PostScript 和 LaTeX 中,您可以使用表示法 x^{superscript} 和 x_{subscript} 得到上标文字。还要注意缩写的终端和输出命令:

例 15  eps 驱动程序的能力

set term post enh    # enhanced PostScript, essentially PostScript with bounding boxes
set out 'gplt.eps'
set xlabel '{/Symbol q_1}
set ylabel 'sin^2({/Symbol q_1})'
plot sin(x)**2

其他

顺便说一下,我们提供的所有例子都可以在交互模式或批处理模式下运行。要以交互模式运行,在提示符中输入每个命令。要以批处理模式运行,将命令输入或添加到文本文件中,然后在 gnuplot提示符中使用 load 'filename' 读入文件,或者在 shell 提示符下将其作为参数提供给 gnuplot$ gnuplot filename。使用第二种方法,gnuplot会在执行输入文件中的所有命令后退出,所以当直接绘图到文件中时,采用批处理模式执行特别有效。如果在屏幕上绘图时使用第二种方法,输出窗口一出现(当 gnuplot退出时)就会消失,所以您需要使用显式的“pause -1”命令(请参阅 help pause)来保持窗口。

在 环境下,gnuplot 如同其他 X client 程序一样,可接受许多参数。如 

gnuplot -font 8x13bold      # 设定字形为 8x13bold。
gnuplot -geometry 900x700  # 设定窗口的长为 900 pixel 宽为 700 pixel。
gnuplot -bg black            # 设定背景颜色为黑色。

gnuplot 绘制数学函数或数值资料的步骤大体如:

定义常数及函数:定义常数及函数,使程式模组化及易于了解。

设定绘图环境:gnuplot 绘图之前已预先设定许多绘图参数。

绘图:在定义数学函数或设定绘图环境之后,接着就是绘出数学函数或数值资料的图形。gnuplot 提供操作方便的绘图指令——plot (2D) 或 splot (3D)

产生输出结果:在终端上绘出结果后,可经由一些步骤而产生不同输出装置所需的输出。

依照上述过程,可快速地画出图形。剩下的步骤就是细心的调整绘图环境参数或修改函数方程式、常数等,即可得到满意的结果。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment