Graphic rendering tool: Gnuplot

Source: Internet
Author: User

Graphic rendering tool: Gnuplot
Introduction to Gnuplot

Gnuplot is a powerful cross-platform plotting tool. From drawing various mathematical function diagrams to writing scientific papers and implementing various complex data formulas, it can easily deal with them. Adhering to the excellent tradition of UNIX, gnuplot uses plain text as the input. Due to its large number of commands and variables, gnuplot has an unparalleled expressiveness. The following two figures are the masterpiece of gnuplot:

If you are interested in gnuplot plotting, refer to the manual on its official website. There are a lot of examples.

Draw a sequence chart-use Gnuplot

Tpcc-MySQL test and use Gnuplot to generate charts

RH442 strategy-Gnuplot

Use Gnuplot in Ubuntu to visualize data

Use oprofile to analyze fortran and use Gnuplot to draw shell scripts

Install Gnuplot 4.6.0 in Ubuntu

Insert a business background

In my previous article, I introduced a one-click tool for creating a blackhole slave database. As mentioned in this article, one function of blackhole slave database is to serve as a data source of an analytic program. In fact, several key data indicators related to Weibo, including users, followers, blog posts, forwarding, comments, and private messages, have all set up corresponding blackhole slave databases, our analysis program regularly parses binlogs to analyze the user activity in a certain period of time. To obtain near-timely statistics, I use crontab to execute flush logs on the blackhole slave database every five minutes, and then analyze the log to be cut. In this way, you can immediately obtain user activity statistics with a granularity of 5 minutes, save them to the database, and use various methods to display the statistics, such as period-over-period comparison, year-over-year comparison, and average value.

Plot using gnuplot

With data, you can plot data using rrdtool, excel, and google APIs. My requirement is to send the statistical data of the previous day by regular mail at ten o'clock A.M. every day, with an intuitive graphic description attached. In the end, I chose gnuplot for plotting. The attached data is as follows (the data is not real data. There are 7 columns in total, with the date and time as a column. Do not confuse them ):

03:45:16 1893 61564 28476 37180 265190 8794
03:50:16 1823 60016 27296 38648 276206 8753
03:55:15 1606 58628 26688 32292 262998 8377
04:00:15 1539 57988 25628 36472 249984 8079
04:05:14 1641 58552 25432 35064 233832 7493
04:10:16 1731 59808 25108 36348 235218 6909
04:15:15 1720 56444 24124 38072 228382 6892
04:20:15 1680 53952 23088 38480 233300 6742
04:25:14 1582 53600 22420 37072 232974 6477
04:30:16 1531 53560 22612 37896 229090 6168

The plot script is as follows:


#! /Usr/bin/gnuplot
Set terminal png # The output format is png.
Set output "image_output_file.png" # specify the data file name
Set title "KPI"
Set ylabel 'net addcount'
Set yrange [0: 700000] # set the range of the Y axis

Set key right top height 3 spacing 2 # set legend
Set border 3 lt 3 lw 2 # This will make the border of your coordinate chart look better
Set grid # display grid
Set key box # It installs the legend in a box
Set xtics nomirror rotate # Only one X axis is required
Set ytics mirror # Only one Y axis is required
Set mytics 5 # You can increase the score scale
Set mxtics 1

Set pointsize 0.4 # pixel size of a vertex
Set datafile separator '\ t' # Separate data file fields with \ t

# Note that table data is exported by tab by default.
Set xdata time # X axis represents time
Set timefmt "% Y-% m-% d % H: % M: % S" # time format in the data file
Set format x "% Y-% m-% d % H: % M" # data displayed on the x axis

# Set the image size to twice the standard size
Set size 2.3, 2
Plot 'unit_data.txt 'using w lp lt 1 lw 2 title "second column", 'unit_data.txt' using w lp lt 2 lw 2 pt 7 title "third column ", 'unit_data.txt 'using w lp lt 3 lw 2 title "fourth column", 'unit_data.txt' using w lp lt 4 lw 2 title "Fifth Column ", 'unit_data.txt 'using w lp lt 5 lw 2 title "", 'unit_data.txt' using w lp lt 6 lw 2 title ""

The script reads the data in unit_data.txt, uses the first column (date and time) as the X axis, and 2nd to seven columns as the Y axis to display 6 different curves, for example:

 

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.