 1 Basic Data Visualization. IPython An interactive shell to execute Python script. Run from a shell; ipython 2.

Slides:



Advertisements
Similar presentations
Graphing With Excel.
Advertisements

Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
Excel 2007 Graphs & Charts. TYPES OF CHARTS Column Bar Pie Line.
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
MATLAB GRAPHICS 2-D.
Charts and Macros Pretty Pictures. Charts Graphical display of information Often referred to as “Visualization” Allows a more innate grasp of numeric.
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
How To Make Graphs in Microsoft Excel Outline Making Bar Graphs Making Scatter Plots – 1 series Making Scatter Plots – Multiple Series.
NU Data Excel Orientation Graphing of Screening Data and Basic Graphing Functions.
Python plotting for lab folk Only the stuff you need to know to make publishable figures of your data. For all else: ask Sourish.
Starter 1.Find the median of Find the median of Calculate the range of Calculate the mode.
An introduction to Plotting in MATLAB Rikard Johansson Department of Biomedical Engineering (IMT) Linköping University
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
MLOSS: Whistler 2008 scientific visualisation for python John Hunter Tradelink Chicago
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
Graphing Behavioral Data for FBA/BIP Special Services Baldwin County Public Schools.
06. Excel Charts. File -> Open -> 06b-datastart.xlsx.
Data Presentation & Graphing Introduction to Mechanical Engineering The University of Texas-Pan American College of Science and Engineering.
3-D Visualization of Cataclysmic Variables with Interactive Data Language(IDL) by: Deidrick Capers.
Creating Charts for the Agency Budget Creating Budget Charts, Slide 1Copyright © 2004, Jim Schwab, University of Texas at Austin.
Name : Tatiana “Tania” Harrison Office : 216 Phone number: CWU page: Syllabus Name :
Getting Started with TI-Interactive. TI-Interactive TI-Interactive can be used to create a variety of graphs. Scatter Plots, Line Plots, Histograms, Modified.
Excel chapter 4.
1. Chapter 15 Creating Charts 3 Charting Data in Word A chart or graph presents data visually. A chart depicts numeric data in a graphical format. If.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
UW CSE 190p Section 7/26, Summer 2012 Dun-Yu Hsiao.
Graphs and How to Use Them. Graphs Visually display your results and data Allow you (and your peers) to see trends Help to make conclusions easier Are.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Matplotlib A python 2D plotting library  Publication quality figures in several hardcopy formats and interactive environments.
Making Bar Graphs and Scatter Plots in Microsoft Excel 2007.
LOGO Chapter 4 Charts 1. LOGO What is a Chart?  Charts are visual representations of worksheet data. Charts often makes it easier to understand the data.
Practical Kinetics Exercise 0: Getting Started Objectives: 1.Install Python and IPython Notebook 2.print “Hello World!”
Matplotlib SANTHOSH Boggarapu.
Great way to show your data!. * In your journal, draw a 4 square grid.
Jeff Howbert Introduction to Machine Learning Winter Machine Learning MATLAB Essentials.
Python & NetworkX Youn-Hee Han
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
How make a scatter graph using Microsoft Excel. Once Excel is Opened: Input the values from the table into Excel. –Don’t forget the labels. It should.
By Christy Quattrone Click to View Types of Graphs Data Analysis, Grade 5.
VBk Practical Mathematics and Microsoft Excel Course Line graphs WINCHESTER COLLEGE.
EEE 242 Computer Tools for Electrical Engineering
Session III Plotting in MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU MATLAB Tutorials.
Introducing Tim Sheerman-Chase This work is licensed under a Creative Commons Attribution 3.0 Unported License 28 th Sept 2011.
CS 5163 Introduction to Data Science
How To Draw Well in Paper
Graphing With Excel.
Excel Charts and Graphs
Lecture 25.
Excel Part 4 Working with Charts and Graphics
IPYTHON AND MATPLOTLIB Python for computational science
Excel Part 4 Working with Charts and Graphics
Microsoft Excel 2003 Illustrated Complete
Prepared by Kimberly Sayre and Jinbo Bi
Assignment #12 “Off the chart!”
PYTHON Prof. Muhammad Saeed.
INTRODUCTION TO SGPLOT Zahir Raihan OVERVIEW  ODS Graphics  SGPLOT overview  Plot Content  High value plot statements  High value plot options 
Python plotting curves chapter 10_5
Matplotlib.
Advanced Plotting Techniques
Interpolation and curve fitting
PYTHON Graphs Prof. Muhammad Saeed.
S4 – Weather Unit Image copyright Joseph Kerski.
Python for Data Analysis
Matplotlib and Pandas
Excel Part 4 Working with Charts and Graphics
Microsoft PowerPoint Tutorial Graphs BIS 101 Spring 2018.
Presentation transcript:

 1 Basic Data Visualization

IPython An interactive shell to execute Python script. Run from a shell; ipython 2

IPython Notebook An interactive web-based Python coding environment. 3

4 CELL Click RUN or SHIFT+ENTER Add a new cell

5 OUTPUT CELL Move the selected cell below Move the selected cell above

6 Restart the running Python Save this notebook Change the cell type

7 After clicking the run button,

Information Visualization 8 Information visualization is increasingly getting its importance. A good visualization could provide more depth knowledge and intuition about data. Python provides a wonderful plotting library very similar to Matlab. Namely, matplotlib (pylab)

Why python plotting? 9 Excel is doing super good! My reasons to use Python for plotting Python to process data. No need to use a Mouse. Vector Graphics (not in matlab) Python code is reusable with minimum efforts. Variety in the type of graphs and annotations Vast support from open source community.

Basic Visualization 10 Provided Visualizations Line / Bar Graph Scatter Plot Box (Whisker) Plot The drawing ability is implemented in an external module.

Basic NumPy 11 NumPy is a library to provide matrix operations. NumPy is a versatile tool for many scientific problems. import numpy as np X = np.linspace(-np.pi, np.pi, 256, endpoint=True) (C, S) = (np.cos(X), np.sin(X))

12 Simple Plot

import pylab as pl import numpy as np X = np.linspace(-np.pi, np.pi, 256, endpoint=True) C, S = np.cos(X), np.sin(X) pl.plot(X, C) pl.plot(X, S) pl.show() ml#matplotlib.pyplot.plot

Changing colors and line widths... pl.figure(figsize=(10, 6), dpi=80) pl.plot(X, C, color="blue", linewidth=2.5, linestyle="-") pl.plot(X, S, color="red", linewidth=2.5, linestyle="-")... 15

Setting limits... pl.xlim(X.min() * 1.1, X.max() * 1.1) pl.ylim(C.min() * 1.1, C.max() * 1.1) The minimum and the maximum of x axis The minimum and the maximum of y axis What if the minimum is positive? ml#matplotlib.pyplot.xlim ml#matplotlib.pyplot.ylim nerated/numpy.ndarray.min.html

Setting limits... pl.xticks( [-np.pi, -np.pi/2, 0, np.pi/2, np.pi], [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$']) pl.yticks( [-1, 0, +1], [r'$-1$', r'$0$', r'$+1$']) The tick numbers in x-axis The tick labels in x-axis ml#matplotlib.pyplot.xticks ml#matplotlib.pyplot.yticks

Moving spines... ax = pl.gca() # gca stands for 'get current axis' ax.spines['right'].set_color('none') ax.spines['top'].set_color('none') ax.xaxis.set_ticks_position('bottom') ax.spines['bottom'].set_position(('data',0)) ax.yaxis.set_ticks_position('left') ax.spines['left'].set_position(('data',0)) ml#matplotlib.pyplot.gca

Moving spines... pl.plot(X, C, color="blue", linewidth=2.5, linestyle="-", label="cosine") pl.plot(X, S, color="red", linewidth=2.5, linestyle="-", label="sine”) pl.legend(loc='upper left')... ml#matplotlib.pyplot.legend

Scatter Plot n = 1024 X = np.random.normal(0,1,n) Y = np.random.normal(0,1,n) T = np.arctan2(Y, X) pl.axes([0.025, 0.025, 0.95, 0.95]) pl.scatter(X, Y, s=75, c=T, alpha=.5) 26 axes(): scatter():

Annotate Some Points t = 2 * np.pi / 3 pl.plot([t, t], [0, np.cos(t)], color='blue', linewidth=2.5, linestyle="--") pl.scatter([t, ], [np.cos(t), ], 50, color='blue’) pl.annotate(r'$sin(\frac{2\pi}{3})=\frac{\sqrt{3}}{2}$', xy=(t, np.sin(t)), xycoords='data’, xytext=(+10, +30), textcoords='offset points', fontsize=16, arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2")) Reference:

Annotate Some Points pl.plot([t, t],[0, np.sin(t)], color='red', linewidth=2.5, linestyle="--") pl.scatter([t, ],[np.sin(t), ], 50, color='red’) pl.annotate(r'$cos(\frac{2\pi}{3})=-\frac{1}{2}$', xy=(t, np.cos(t)), xycoords='data’, xytext=(-90, -50), textcoords='offset points', fontsize=16, arrowprops=dict(arrowstyle="-> », connectionstyle="arc3,rad=.2")) 29

Transparent Tick Labels... for label in ax.get_xticklabels() \ + ax.get_yticklabels(): label.set_fontsize(16) label.set_bbox(dict(facecolor='white', edgecolor='None', alpha=0.65)) …

Subplot pl.figure(figsize=(6, 4)) pl.subplot(2, 1, 1) pl.xticks(()) pl.yticks(()) pl.text(0.5, 0.5, 'subplot(2,1,1)', ha='center', va='center’, size=24, alpha=.5) pl.subplot(2, 1, 2) pl.xticks(()) pl.yticks(()) pl.text(0.5, 0.5, 'subplot(2,1,2)', ha='center', va='center’, size=24, alpha=.5) pl.tight_layout() pl.show() 33

Subplot How to? 35

pl.axes([.1,.1,.8,.8]) pl.xticks(()) pl.yticks(()) pl.text(.6,.6, 'axes([0.1,0.1,.8,.8])', ha='center', va='center’, size=20, alpha=.5) pl.axes([.2,.2,.3,.3]) pl.xticks(()) pl.yticks(()) pl.text(.5,.5, 'axes([0.2,0.2,.3,.3])', ha='center', va='center’, size=16, alpha=.5) pl.show() 37

Bar Plots n = 12 X = np.arange(n) Y1 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) Y2 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) pl.bar(X, +Y1, facecolor='#9999ff', edgecolor='white') pl.bar(X, -Y2, facecolor='#ff9999', edgecolor='white’) for x, y in zip(X, Y1): pl.text(x + 0.4, y , '%.2f' % y, ha='center', va='bottom’) pl.ylim(-1.25, +1.25) 39 ml#matplotlib.pyplot.bar nerated/numpy.arange.html

40

Contour Plot def f(x, y): return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 -y ** 2) n = 256 x = np.linspace(-3, 3, n) y = np.linspace(-3, 3, n) X, Y = np.meshgrid(x, y) pl.contourf(X, Y, f(X, Y), 8, alpha=.75, cmap='jet') C = pl.contour(X, Y, f(X, Y), 8, colors='black', linewidth=.5) 41 d/numpy.meshgrid.html ml#matplotlib.pyplot.contourf

42

Contour Plot def f(x, y): return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2) n = 10 x = np.linspace(-3, 3, 4 * n) y = np.linspace(-3, 3, 3 * n) X, Y = np.meshgrid(x, y) pl.imshow(f(X, Y)) 43 ml#matplotlib.pyplot.imshow

44

Pie Chart Z = np.random.uniform(0, 1, 20) pl.pie(Z) 45 ml#matplotlib.pyplot.pie

46

Quiver Plot for Vector Field n = 8 X, Y = np.mgrid[0:n, 0:n] pl.quiver(X, Y) 47 ml#matplotlib.pyplot.quiver

48

Grid Drawing ax.set_xlim(0,4) ax.set_ylim(0,3) ax.xaxis.set_major_locator(pl.MultipleLocator(1.0)) ax.xaxis.set_minor_locator(pl.MultipleLocator(0.1)) ax.yaxis.set_major_locator(pl.MultipleLocator(1.0)) ax.yaxis.set_minor_locator(pl.MultipleLocator(0.1)) ax.grid(which='major', axis='x', linewidth=0.75, linestyle='-', color='0.75') ax.grid(which='minor', axis='x', linewidth=0.25, linestyle='-', color='0.75') ax.grid(which='major', axis='y', linewidth=0.75, linestyle='-', color='0.75') ax.grid(which='minor', axis='y', linewidth=0.25, linestyle='-', color='0.75') ax.set_xticklabels([]) ax.set_yticklabels([]) 49

50

Polar Axis ax = pl.axes([0.025, 0.025, 0.95, 0.95], polar=True) N = 20 theta = np.arange(0., 2 * np.pi, 2 * np.pi / N) radii = 10 * np.random.rand(N) width = np.pi / 4 * np.random.rand(N) bars = pl.bar(theta, radii, width=width, bottom=0.0) for r, bar in zip(radii, bars): bar.set_facecolor(cm.jet(r / 10.)) bar.set_alpha(0.5) 51 ot.axes

52

3D Plot import numpy as np from mpl_toolkits.mplot3d import Axes3D fig = pl.figure() ax = Axes3D(fig) X = np.arange(-4, 4, 0.25) Y = np.arange(-4, 4, 0.25) X, Y = np.meshgrid(X, Y) R = np.sqrt(X ** 2 + Y ** 2) Z = np.sin(r) ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=pl.cm.hot) ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=pl.cm.hot) ax.set_zlim(-2, 2) pl.show() 53 t3d/tutorial.html