آشنایی با پکج MATPLOTLIB
خلهصه مطالب:
●
●
MATPLOTLIBچیست ؟
پل ت های ساده
●
فراتر از پل ت ها ی ساده
●
MATPLOTLIBو ...
●
چرا MATPLOTLIB؟
●
منابع مورد استفاده
MATPLOTLIBچیست؟
MATPLOTLIBیک کتابخانه برای پل ت کردن انواع نمودار ها است که به
همراه کتابخانه NumPyدر محیط زبان برنامه نویسی پایتون قابل استفاده
یباشد
م ب
پل ت های ساده
"""
Simple demo of a horizontal bar chart.
"""
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))
error = np.random.rand(len(people))
plt.barh(y_pos, performance, xerr=error,
align='center', alpha=0.4)
plt.yticks(y_pos, people)
plt.xlabel('Performance')
plt.title('How fast do you want to go today?')
plt.show()
پل ت های ساده
"""
Simple demo of the fill function.
"""
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 1)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)
plt.fill(x, y, 'r')
plt.grid(True)
plt.show()
پل ت های ساده
"""
Demo of a simple plot with a custom dashed line.
A Line object's ``set_dashes`` method allows you to
specify dashes with
a series of on/off lengths (in points).
"""
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10)
line, = plt.plot(x, np.sin(x), '--', linewidth=2)
dashes = [10, 5, 100, 5] # 10 points on, 5 off, 100
on, 5 off
line.set_dashes(dashes)
plt.show()
پل ت های ساده
Demo of a basic pie chart plus a few additional features.
In addition to the basic pie chart, this demo shows a few optional features:
* slice labels
* auto-labeling the percentage
* offsetting a slice with "explode"
* drop-shadow
* custom start angle
Note about the custom start angle:
The default ``startangle`` is 0, which would start the "Frogs" slice on the
positive x-axis. This example sets ``startangle = 90`` such that everything is
rotated counter-clockwise by 90 degrees, and the frog slice starts on the
positive y-axis.
"""
import matplotlib.pyplot as plt
# The slices will be ordered and plotted counter-clockwise.
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=90)
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
plt.show()
پل ت های ساده
پل ت های ساده
پل ت های ساده
پل ت های ساده
فراتر از پل ت های ساده
فراتر از پل ت های ساده
#!/usr/bin/env python
import numpy as np
from matplotlib.pyplot import figure, show, rc
# radar green, solid grid lines
rc('grid', color='#316931', linewidth=1, linestyle='-')
rc('xtick', labelsize=15)
rc('ytick', labelsize=15)
# force square figure and square axes looks better for
polar, IMO
fig = figure(figsize=(8,8))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True,
axisbg='#d5de9c')
r = np.arange(0, 3.0, 0.01)
theta = 2*np.pi*r
ax.plot(theta, r, color='#ee8d18', lw=3, label='a line')
ax.plot(0.5*theta, r, color='blue', ls='--', lw=3,
label='another line')
ax.legend()
show()
فراتر از پل ت های ساده
فراتر از پل ت های ساده
فراتر از پل ت های ساده
فراتر از پل ت های ساده
فراتر از پل ت های ساده
فراتر از پل ت های ساده
... وMATPLOTLIB
: قابلیت استفاده از این کتابخانه به همراه
●
●
●
●
wxPython,QT4,GTK+ GUI TOOLKITS
EXCEL DATA HANDLING
BASEMAP:GEOGRAPHIC IMAGE
TOOLKIT
MATPLOT3D:3D PLOTTING TOOL
چرا MATPLOTLIB؟
●
متن باز بودن
●
آسانی یادگیری آن برای کاربران MATLAB
●
امکان استفاده از آن در کنار بسیاری از کتابخانه های دیگر در محیط پایتون
●
فراهم نمودن توانایی امبد کردن تصاویر در نرم افزار های ساخته شده با پایتون
●
پشتیبانی کامل از لتک و امکان استفاده آن در محیط اینترنت
منابع مورد استفاده
●
http://en.wikipedia.org/wiki/Matplotlib
●
WWW.MATPLOTLIB.ORG
●
WWW.PYTHON.ORG
پایان
© Copyright 2025