Table of Contents
3D绘图
输出文件
其他
Home Database Mysql Tutorial gnuplot 入门教程 2

gnuplot 入门教程 2

Jun 07, 2016 pm 03:39 PM
gnuplot thing Getting Started Tutorial

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

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

3D绘图

例 11:

1

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

Copy after login

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

gnuplot 入门教程 2

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

例 12 画等高线图:

1

2

3

4

5

6

7

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)

Copy after login

gnuplot 入门教程 2

例 13 画pm3d

1

2

3

set pm3d

set isosamples 50,50

splot x**2+y**2

Copy after login
gnuplot 入门教程 2

1

2

3

4

5

set view 0,0 #设置视角,(0,0)将投影到底面上去

unset ztics #把z轴上的数字给去掉

unset surface

splot x**2+y**2

reset

Copy after login
gnuplot 入门教程 2

输出文件

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

例 14 设置输出和终端类型

1

2

3

set terminal png     # gnuplot recommends setting terminal before output

set output ‘output.png’  # The output filename

plot sin(x)

Copy after login

现在,文件 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 驱动程序的能力

1

2

3

4

5

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

Copy after login

其他

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

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

1

2

3

gnuplot -font 8x13bold      # 设定字形为 8x13bold。

gnuplot -geometry 900x700  # 设定窗口的长为 900 pixel 宽为 700 pixel。

gnuplot -bg black            # 设定背景颜色为黑色。

Copy after login

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

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

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

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

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

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


Statement of this Website
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

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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed introduction to what wapi is Detailed introduction to what wapi is Jan 07, 2024 pm 09:14 PM

Users may have seen the term wapi when using the Internet, but for some people they definitely don’t know what wapi is. The following is a detailed introduction to help those who don’t know to understand. What is wapi: Answer: wapi is the infrastructure for wireless LAN authentication and confidentiality. This is like functions such as infrared and Bluetooth, which are generally covered near places such as office buildings. Basically they are owned by a small department, so the scope of this function is only a few kilometers. Related introduction to wapi: 1. Wapi is a transmission protocol in wireless LAN. 2. This technology can avoid the problems of narrow-band communication and enable better communication. 3. Only one code is needed to transmit the signal

PHP implementation framework: CakePHP introductory tutorial PHP implementation framework: CakePHP introductory tutorial Jun 18, 2023 am 09:04 AM

With the continuous development of Internet technology, Web development technology is also constantly updated and iterated. As an open source programming language, PHP is widely used in web development. As one of the commonly used tools in PHP development, the PHP framework can improve development efficiency and code quality. This article will introduce you to a PHP framework - CakePHP, and provide some simple tutorials to get started. 1. What is CakePHP? CakePHP is a model based on MVC (Model-View-Control

CentOS installation gnuplot and CentOS installation sunflower are missing dependencies CentOS installation gnuplot and CentOS installation sunflower are missing dependencies Feb 13, 2024 pm 11:39 PM

LINUX is a widely used operating system that is highly customizable and stable. CentOS is a free and open source operating system built on the Red Hat Enterprise Linux (RHEL) source code. It is widely used in servers and desktop environments. In CentOS Installing software packages on CentOS is one of the common tasks in daily use. This article will introduce how to install gnuplot on CentOS and solve the problem of missing dependencies of Sunflower software. Gnuplot is a powerful drawing tool that can generate various types of charts, including two-dimensional and three-dimensional data visualization. To install gnuplot on CentOS, you can follow the steps below: 1.

Beginner's Guide: Start from scratch and learn MyBatis step by step Beginner's Guide: Start from scratch and learn MyBatis step by step Feb 19, 2024 am 11:05 AM

Concise and easy-to-understand MyBatis introductory tutorial: write your first program step by step MyBatis is a popular Java persistence layer framework that simplifies the process of interacting with databases. This tutorial will show you how to use MyBatis to create and perform simple database operations. Step 1: Environment setup First, make sure your Java development environment has been installed. Then, download the latest version of MyBatis and add it to your Java project. You can download it from the official website of MyBatis

PHP implementation framework: Lumen framework introductory tutorial PHP implementation framework: Lumen framework introductory tutorial Jun 18, 2023 am 08:39 AM

Lumen is a PHP-based microframework developed by Laravel framework developers. It was originally designed to quickly build small API applications and microservices, while retaining some components and features of the Laravel framework. The Lumen framework is lightweight, fast, and easy to use, so it has received widespread attention and use. In this article, we will quickly get started with the Lumen framework and learn how to use the Lumen framework to build simple API applications. Framework preparation Before learning the Lumen framework, we need to

Getting started with the Python Flask framework Getting started with the Python Flask framework Jun 17, 2023 am 08:48 AM

PythonFlask framework introductory tutorial Flask is a simple and easy-to-use Python Web framework. It pays more attention to flexibility and lightweight, allowing programmers to build according to their own preferences. This article will introduce you to the basic concepts, installation and use of Flask, and use a simple example to demonstrate how to use Flask to build a web application. What is Flask? Flask is a lightweight web application framework based on Python that does not require the use of any special

Java Email Sending Guide: Easy Getting Started and Practical Demonstrations Java Email Sending Guide: Easy Getting Started and Practical Demonstrations Dec 27, 2023 am 09:17 AM

Java Email Sending Tutorial: Quick Start and Example Demonstration In recent years, with the popularity and development of the Internet, email has become an indispensable part of people's daily life and work. Sending emails through the Java programming language can not only achieve fast and efficient email sending, but also greatly improve work efficiency through automation. This article will introduce how to use the JavaMail library to send emails in Java and demonstrate it through specific code examples. Step 1: Import and configure the JavaMail library first

PHP implementation framework: ThinkPHP introductory tutorial PHP implementation framework: ThinkPHP introductory tutorial Jun 18, 2023 pm 09:42 PM

With the continuous development of Internet technology, various languages ​​​​and frameworks have also emerged. As a widely used scripting language, PHP is widely used in website development. Among the PHP frameworks, ThinkPHP is a very excellent framework that provides powerful functions and good performance. Using it can greatly improve the efficiency of website development. In this article, we will introduce you to the introductory tutorial of the ThinkPHP framework to help you quickly master this excellent framework. 1. What is ThinkPHPTh?

See all articles