Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Use matplotlib scientific drawing in Linux     - How to install new fonts on Ubuntu 14.04 and 14.10 (Linux)

- Ubuntu users to install household financial management tools HomeBank 5.0.0 (Linux)

- Deepin Tutorial: Depth Description Installer expert mode (Linux)

- shell script: LVS start simple script (Server)

- Learn about EditText little depth (Programming)

- Troubleshooting Linux virtual machine device id and the letter of inconsistencies (Linux)

- CentOS6.x and Windows XP and Windows Server 2003 Open IPv6 related matters (Linux)

- Vim custom color (Linux)

- Linux POST fstab configuration file read-only variable can not be modified problem (Linux)

- Oracle online redefinition (Database)

- Network security system (Network)

- To install minimize RHEL / CentOS 7 (Linux)

- Seven Steps to Help Google Chrome Speed - (Linux)

- Windows using SSH management Ubuntu (Linux)

- Under CentOS yum install Nginx smooth switch mounted to Tengine (Server)

- Linux Thread Synchronization (Programming)

- GitLab Guide installation under Ubuntu 14.04 (Server)

- Linux 4.0+ kernel support for hardware switching module (HW Switch Offload) (Linux)

- When RHEL7 use fdisk partition, all partitions can not be used (Linux)

- Linux how to view the graphics models notebook (Linux)

  Use matplotlib scientific drawing in Linux
  Add Date : 2017-08-31      
  If you want to get in Linxu in an efficient, automated, high-quality scientific drawing solution you should consider trying the next matplotlib library. Matplotlib is an open source package python-based mapping science, publishing python-based Software Foundation license. Extensive documentation and examples, integrated with Python and Numpy scientific computing package, and automation capabilities, as a Linux environment for reliable scientific drawing select few reasons. This tutorial will provide several examples with matplotlib drawing.


It supports many chart types, such as: bar, box, contour, histogram, scatter, line plots ....
Based on python syntax
Integrated Numpy scientific computing package
The data source can be a list of the python, and an array of key-value pairs
Customizable chart format (axis scaling, label position and labeling content, etc.)
Customizable text (font, size, position ...)
Support TeX format (equations, symbols, Greek fonts ...)
Compatible with IPython (allowed to interact with the chart in the python shell)
Automation (create a chart using Python loop)
Generate a picture of loop iterations Python
Save depicted image format image files, such as: png, pdf, ps, eps, svg etc.
Python-based grammar matplotlib is the basis for many of its features and efficient workflows. Many used to draw the world face very high-quality scientific graphics package, but these packages allow you to direct your Python code to use it? In addition, these packages allow you to create image files can be saved as a picture of it? Matplotlib allows you to do all of these tasks. So you can save time, you can use it to spend less time to create more images.


Install Python and Numpy package is used Matplotlib premise Numpy installation guidelines can be found at the link.

Matplotlib can be installed in Debian or Ubuntu by the following command:

$ Sudo apt-get install python-matplotlib
In Fedora or CentOS / RHEL environment, you can use the following command:

$ Sudo yum install python-matplotlib
Matplotlib examples

This tutorial provides several examples demonstrate how to use the drawing matplotlib:

Scatter charts and line graph
pie chart
In these examples we will use the Python script to perform Mapplotlib command. Note numpy and matplotlib modules need to import Import command in the script.

np nuupy namespace reference to the module, plt to matplotlib.pyplot namespace references:

import numpy as np
import matplotlib.pyplot as plt

Example 1: discrete and linear plot

The first script, script1.py complete the following tasks:

Create three data sets (xData, yData1 and yData2)
Create a 8 inches wide, 6 inches high figure (assignment 1)
Setting the title picture, x-axis labels, y-axis labels (both size 14)
Draw the first data set: yData1 xData as a function of the data set with discrete dots Blue Line logo, identified as "y1 data"
Draw a second data set: yData2 xData as a function of the data set, using red solid lines, identified as "y2 data"
In the upper left corner of the graph legend placed
Save as PNG image file format
Script1.py contents are as follows:

import numpy as np
import matplotlib.pyplot as plt
xData = np.arange (0,10,1)
yData1 = xData .__ pow __ (2.0)
yData2 = np.arange (15,61,5)
plt.figure (num = 1, figsize = (8,6))
plt.title ( 'Plot 1', size = 14)
plt.xlabel ( 'x-axis', size = 14)
plt.ylabel ( 'y-axis', size = 14)
plt.plot (xData, yData1, color = 'b', linestyle = '-', marker = 'o', label = 'y1 data')
plt.plot (xData, yData2, color = 'r', linestyle = '-', label = 'y2 data')
plt.legend (loc = 'upper left')
plt.savefig ( 'images / plot1.png', format = 'png')

Example 2: Histogram

The second script, script2.py complete the following tasks:

Create a 1000 random sample of normally distributed data sets.
Create a 8 inches wide, 6 inches high figure (assignment 1)
Title set figure, x-axis labels, y-axis labels (both size 14)
With samples of the data set to draw a 40 column, while the histogram from -10 to 10
Add text to display the Greek letter mu and sigma with TeX format (size 16)
Save the picture in PNG format.
script2.py code is as follows:

import numpy as np
import matplotlib.pyplot as plt
mu = 0.0
sigma = 2.0
samples = np.random.normal (loc = mu, scale = sigma, size = 1000)
plt.figure (num = 1, figsize = (8,6))
plt.title ( 'Plot 2', size = 14)
plt.xlabel ( 'value', size = 14)
plt.ylabel ( 'counts', size = 14)
plt.hist (samples, bins = 40, range = (- 10,10))
plt.text (-9,100, r '$ \ mu $ = 0.0, $ \ sigma $ = 2.0', size = 16)
plt.savefig ( 'images / plot2.png', format = 'png')

Example 3: Pie Chart

The third script, script3.py complete the following tasks:

Create a list of 5 integers containing
Create a 6 inches wide, 6 inches high figure (assignment 1)
Adding an aspect ratio of a-axis of FIG.
FIG set title (font size 14)
Videos with tag data list contains a pie chart
Pictured save PNG format
Script3.py script code is as follows:

import numpy as np
import matplotlib.pyplot as plt
data = [33,25,20,12,10]
plt.figure (num = 1, figsize = (6,6))
plt.axes (aspect = 1)
plt.title ( 'Plot 3', size = 14)
plt.pie (data, labels = ( 'Group 1', 'Group 2', 'Group 3', 'Group 4', 'Group 5'))
plt.savefig ( 'images / plot3.png', format = 'png')

to sum up

This tutorial provides several use matplotlib scientific drawing package drawing example, Matplotlib is used to solve the great scientific drawing program, its performance in seamlessly and Python in a Linux environment, Numpy connection, automation capabilities, and provide more kind custom quality paint products. Documentation and examples matplotlib packages see here.
- How to install Ubuntu applications Device 7 (Linux)
- Use SocketServer write a sockets program (Programming)
- Oracle Listener can not start (TNS-12555, TNS-12560, TNS-00525) (Database)
- Use Python to perform system commands common usage (Programming)
- mysqldump implement database logical backup (Database)
- How to use Linux to download music from Grooveshark (Linux)
- Oracle index visible and hidden (visible / invisible) (Database)
- Nginx + Tomcat static and dynamic load balancing and separation configuration essentials under Linux (Server)
- Linux Network Analysis Tcpdump Command Guide (Linux)
- Oracle 11g manually create a database (Database)
- MySQL InnoDB table --BTree basic data structures (Database)
- Linux basis: a comprehensive study pwd command (Linux)
- Let your PHP 7 faster (GCC PGO) (Linux)
- Https (SSL / TLS) Detailed principles (Server)
- OpenStack Folsom create an instance of the failure of the Quota Fixed_IP articles (Server)
- Linux MultiPath software implementation instructions (Linux)
- Linux Oracle environment variable is invalid Problem Solving (Database)
- How to write a new Git protocol (Linux)
- Linux modify environment variables method (Linux)
- Oracle Standby Redo Log experiment (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.