PYTHON Prof. Muhammad Saeed.

Slides:



Advertisements
Similar presentations
Unit 9 It's warm 清丰县第一实验小学 唐利娟.
Advertisements

The Coordinate Plane Goal: Plot points on a coordinate plane.
Physics-Informatics Looking for Higgs Particle Counting Errors (Continued) January Geoffrey Fox
© red ©
Graphing Examples Categorical Variables
Graphing A Practical Art. Graphing Examples Categorical Variables.
PYTHON PLOTTING CURVES CHAPTER 10_5 FROM THINK PYTHON HOW TO THINK LIKE A COMPUTER SCIENTIST.
 1 Basic Data Visualization. IPython An interactive shell to execute Python script. Run from a shell; ipython 2.
Introduction to Python Session 2: Beginning Numerical Python and Visualization Jeremy Chen.
418512: Computer Programming Languages Lecture 7 Pramook Khungurn TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA.
Data Analysis Qualitative Data Data that when collected is descriptive in nature: Eye colour, Hair colour Quantitative Data Data that when collected is.
Introduction to Biostatistics and Bioinformatics Exploring Data and Descriptive Statistics.
Learning Objectives Students will identify the seven continents and major bodies of water on a world map. Students will color and label the seven continents.
Visualization UW CSE 140 Winter matplotlib Strives to emulate MATLAB – Pro: familiar to MATLAB users – Pro: powerful – Con: not the best design.
Graphs, Charts and Tables Describing Your Data. Frequency Distributions.
Computerized Graphing By: Ms. Gliot. Qualitative Vs. Quantitative Data 1.What is your favorite color? A. Yellow B. Blue C. Cranberry d. Pink 2.How many.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
UW CSE 190p Section 7/26, Summer 2012 Dun-Yu Hsiao.
Basic Usage of GnuPlot Hyun Hee Shim Department of Physics Kangwon National University.
Recap Plots with More than one Line Plots of Complex Arrays Line, Color and Mark Style Axis Scaling and Annotating Plots Subplots Polar Plots Logarithmic.
Matplotlib A python 2D plotting library  Publication quality figures in several hardcopy formats and interactive environments.
Research Methods: 2 M.Sc. Physiotherapy/Podiatry/Pain Graphs and Tables.
Python & NetworkX Youn-Hee Han
Lecture 17 More Plotting Chapter 12 Matrices. Outline from Chapter D Plotting 11.4 Surface Plots 11.5 Interacting with Plotted Data.
Guess the colour Mix the colours Evaluation Group with work.
CS 5163 Introduction to Data Science
How To Draw Well in Paper
Introduction to python
Barnhart Elementary School, Summer 2000
Creating a picture of your data
Images In Matlab.
Red, socks, yellow, jacket, coat, orange, skirt, black, hat, green, blue, jeans, brown, T-shirt, shoes, white, pink.
IPYTHON AND MATPLOTLIB Python for computational science
Lecture 25: Exploring data
Graphs Class A Class B.
Visualization UW CSE 160 Spring 2018.
Machine Learning in Python Scikit-learn 2 Prof. Muhammad Saeed.
Colors.
PYTHON Prof. Muhammad Saeed.
Sample Column Chart- No Data Labels, no lines SOURCE:
Like.
Barnhart Elementary School, Summer 2000
Graphs.
Average Number of Photons
Unit 6 New school uniforms
Visualization UW CSE 160 Winter 2016.
Python plotting curves chapter 10_5
Visualization UW CSE 160 Winter 2017.
Matplotlib.
Introduction to MATLAB Plotting LAB 3
Interpolation and curve fitting
Can I color yellow?. Can I color yellow?
PYTHON Prof. Muhammad Saeed.
Yang-Ming University, Taipei, Taiwan
Notes on pyplot Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An Introduction.
PYTHON Graphs Prof. Muhammad Saeed.
PYTHON Prof. Muhammad Saeed.
Introduction to Script languages such as Python, PERL, PHP
What Color is it?.
C c Cc is for cat. © ©
Visualization UW CSE 160 Spring 2015.
Season & Weather Unit 5 The four seasons.
Word Work List ____________ Name____________
Graphs.
Help Gina and Tina color the numbers
1-25. Study the pattern of tiles for Tile Pattern I. With your team, complete Figure 4 on the resource page. Complete the table, graph, and equation for.
Matplotlib and Pandas
Colours Дополнительный иллюстративный материал
This is the pre show setup
Jingbo Yang, Andrey Kurenkov
Presentation transcript:

PYTHON Prof. Muhammad Saeed

Python Dept. Of Comp. Sc. & IT, FUUAST Graphs With matplotlib Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST 2D Graphs Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D import matplotlib.pyplot as plt import numpy as np Plot I x= np.arange(-12*pi, 12*pi, 0.15) y=np.exp(-0.05*x)*np.sin(x) plt.plot(x,y,’o-r’,lw=1) plt.title('Damped Oscillator') plt.xlabel('Angle') plt.ylabel('Amplitude') Plot II plt.plot(x, y, alpha = 0.5, color = ‘#FF7F00’, linestyle = ‘-.’, linewidth = 3, marker = ‘o’, markeredgecolor = ‘#000000’, markeredgewidth = 2, markerfacecolor = ‘#FF7F00’, markersize=10) Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D Color, Marker & Line Style Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D Scatter Plot: z = numpy.random.randn(100,2) x=z[:,0] y=z[:,1] plt.scatter(x,y) plt.scatter(x+0.2,y, s = 60, c = ’#FF7F00’, marker=’s’, alpha = .5) Bar Charts: import numpy as np import matplotlib.pyplot as plt y = np.random.randn(5) x = np.arange(5) plt.bar(x,y) Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D Stem Plot: import numpy as np import matplotlib.pyplot as plt x=np.linspace(-2*np.pi,2*np.pi,400) y=np.cos(x)**2 plt.stem(x,y,’-.’,bottom=-2) Stacked Bar Plot: A = [5., 30., 45., 22.] B = [5., 25., 50., 20.] X = range(4) plt.bar(X, A, color = 'b') plt.bar(X, B, color = 'r', bottom = A) Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D Step Plot: import numpy as np import matplotlib.pyplot as plt x = np.linspace(-np.pi,np.pi,40) y = np.sin(x) plt.step(x, y) Histogram x = np.random.randn(1000) plt.hist(x, bins = 30) plt.hist(x, bins = 30, cumulative=True, color='#FF7F00') Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D Pie Chart y = np.random.rand(5) plt.pie(y) ; expld = np.array([.2,0,0,0,0]) clrs = [‘#FF0000','#FFFF00','#00FF00','#00FFFF','#0000FF'] labls = [’One’, ’Two’, ’Three’, ’Four’, ’Five’] plt.pie(y, explode = expld, colors = clrs, labels = labls, autopct = ’%2.0f’, shadow = True) Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D Multiple Graphs ………….. import matplotlib.pyplot as plt Import numpy as np clrs = ['#FF0000','#FFFF00','#00FF00','#00FFFF','#0000FF'] fig,ax = plt.subplots(nrows=2,ncols=2, figsize=(12,8)) ax=np.ravel(ax) y = np.random.randn(100) ax[0].plot(y) ax[0].set_title('1') y = np.random.rand(5) x = np.arange(5) ax[1].bar(x, y) ax[1].set_title('2') Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graph 2D ------ Multiple Graphs y = np.random.rand(5) ax[2].pie(y, colors=clrs) ax[2].set_title('3') z = np.random randn(100, 2) x = z[:, 0] y = z[:, 1] ax[3].scatter(x, y) ax[3].set_title('4') Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST 3D Graphs Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST 3D Graphs 3D curves Import mpl_toolkits.mplot3d.axes3d import matplotlib.pyplot as plt from numpy import sin, cos, linspace, pi x = linspace(-8*pi,8*pi,400) y = x*sin(x) x = 2*cos(x) z = x*y fig = plt.figure() ax=fig.gca(projection='3d') ax.plot(x,y,z) ax.set_title(‘TITLE’) plt.show() #ax.set_axis_off() ; #ax.grid(b=‘off’) Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST 3D Graphs 3D curve import mpl_toolkits.mplot3d.axes3d import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt fig = plt.figure() ax = fig.gca(projection='3d') theta = np.linspace(-8 * np.pi, 8 * np.pi, 200) z = np.linspace(-2, 2, 200) r = z**2+2 x = r * np.sin(theta) y = r * np.cos(theta) ax.plot(x, y, z) plt.show() Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST 3D Graphs 3D Wireframe import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') X = np.arange(-5, 5, 0.2) Y = np.arange(-5, 5, 0.2) X, Y = np.meshgrid(X, Y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R) ax.plot_wireframe(X, Y, Z, rstride=1,cstride=1,lw=1,antialiased=False) plt.show() Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST 3D Graphs 3D curves import mpl_toolkits.mplot3d.axes3d import matplotlib.pyplot as plt import numpy as np fig= plt.figure() ax = fig.add_subplot(111, projection='3d') x = np.arange(-10, 10, 0.2) y = np.arange(-10, 10, 0.2) X, Y = np.meshgrid(x, y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R)/R ax.plot_surface(X, Y, Z, rstride=2, cstride=2, linewidth=0) #ax.set_zlim3d(-1, 1) Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST 3D Graphs Scatter import numpy as np Import mpl_toolkits.mplot3d.axes3d import matplotlib.pyplot as plt def randrange(n, vmin, vmax): return (vmax - vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(111, projection='3d') n = 100 for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]: xs = randrange(n, 23, 32) ys = randrange(n, 0, 100) zs = randrange(n, zl, zh) ax.scatter(xs, ys, zs, c=c, marker=m) ax.set_xlabel('X Label'); ax.set_ylabel('Y Label'); ax.set_zlabel('Z Label') #ax.set_axis_off(); #ax.grid(b='off'); #ax.set_title('Hello') plt.show() Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST L O R S Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST [('Perceptually Uniform Sequential', ['viridis', 'inferno', 'plasma', 'magma']), ('Sequential', ['Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']), ('Sequential (2)', ['afmhot', 'autumn', 'bone', 'cool', 'copper', 'gist_heat', 'gray', 'hot', 'pink', 'spring', 'summer', 'winter']), ('Diverging', ['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'seismic']), ('Qualitative', ['Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3']), ('Miscellaneous', ['gist_earth', 'terrain', 'ocean', 'gist_stern', 'brg', 'CMRmap', 'cubehelix', 'gnuplot', 'gnuplot2', 'gist_ncar', 'nipy_spectral', 'jet', 'rainbow', 'gist_rainbow', 'hsv', 'flag', 'prism'])] Python Dept. Of Comp. Sc. & IT, FUUAST

Python Dept. Of Comp. Sc. & IT, FUUAST Graphs & Colors END Python Dept. Of Comp. Sc. & IT, FUUAST