Graphical Excellence - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Graphical Excellence

Description:

Import Statement. Load modules into interpreter memory. from MODULE import SOMETHING ... from plotData import * plotData(Heroin, 'Heroin') Return Values ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 32
Provided by: emilygreen
Category:

less

Transcript and Presenter's Notes

Title: Graphical Excellence


1
Graphical Excellence
  • CMSC 120 Visualizing Information
  • 2/7/08 Lecture Part II

2
Graphical displays should
  • Show the data
  • Induce the viewer to think about substance, not
  • Methodology
  • Design
  • Technology
  • Tell the truth
  • Make the complex simple
  • Serve a clear purpose
  • Reveal the data

3
Data
4
Visualization
5
Fate of Napoleons Army
Advance
Retreat
Temperature
6
Principles of Graphics Excellence
  • Matter of substance, statistics, and design
  • Communicate complex ideas with clarity,
    precision, and efficiency
  • Give viewer the greatest number of ideas in the
    shortest time, with the least ink, in the
    smallest space

7
A Matter of Substance and Statistics
  • CMSC 120 Visualizing Information
  • 2/7/08 Lecture Part II

8
Data
9
Samples and Populations
  • Law of Large Numbers
  • The more observations we have, the greater the
    understanding we have of the true behavior of a
    system
  • Sample set of observations
  • Population all possible observations

10
Distribution
  • Arrangement of the set of possible solutions
    along a number line

11
Statistical Properties of Data
Max
Min
  • Mean average of all the values (expected value)
  • Median middle value
  • Mode value that occurs most often
  • Variance spread away from the mean
  • Standard Deviation square root of the variance

12
Relational Statistics
  • Covariance spread of values in multiple
    dimensions
  • Correlation how well one measure predicts another

13
Pylab and Python Statistics
  • mean(ltDATAgt)
  • median(ltDATAgt)
  • var(ltDATAgt)
  • std(ltDATAgt)
  • correlate(ltDATAgt)
  • corrcoeff(ltDATAgt)
  • cov(ltDATAgt)

14
Sprechen de Python?
  • CMSC 120 Visualizing Information
  • 2/7/08 Lecture Part III

15
Blocks of code
  • gtgtgt def plotData()
  • plot(Year, Marijuana)
  • show()
  • xlabel('Year')
  • ylabel('Percentage')
  • title('Marijuana Drug Use')
  • Function a block of related code that performs a
    single task
  • def
  • plotData a user-defined keyword

16
Running a Function
gtgtgt plotData()
17
Parameters
gtgtgt def plotData() plot(Year,
Marijuana) show() xlabel('Year')
ylabel('Percentage')
title('Marijuana Drug Use')
  • gtgtgt def plotData2()
  • plot(Year, Heroin)
  • show()
  • xlabel('Year')
  • ylabel('Percentage')
  • title('Heroin Drug Use')

18
Parameters
gtgtgt def plotData() plot(Year,
Marijuana) show() xlabel('Year')
ylabel('Percentage')
title('Marijuana Drug Use')
  • gtgtgt def plotData(data, name)
  • plot(Year, data)
  • show()
  • xlabel('Year')
  • ylabel('Percentage')
  • title(name ' Drug Use')
  • Input
  • Flexibility

19
Parameters
  • gtgtgt plotData(Marijuana, 'Marijuana')

20
Parameters
  • gtgtgt plotData(Heroin, 'Heroin')

21
Functions
  • def ltFUNCTION NAMEgt (ltPARAMTERSgt)
  • ltSOMETHINGgt
  • ltSOMETHINGgt

22
Running a Function
gtgtgt plotData()
  • Traceback (most recent call last)
  • File "ltpyshell5gt", line 1, in ltmodulegt
  • plotData()
  • NameError name 'plotData' is not defined

23
Modules
  • Type the function definition in a text file
  • Save
  • ? SOURCE CODE

24
Modules
  • File plotdata.py
  • Purpose A useful plotting function
  • Author Me
  • Import Pylab
  • from pylab import
  • Import Data
  • from DrugData import
  • Define the function
  • def plotData(data, name)
  • plot(Year, data)
  • show()
  • xlabel('Year')
  • ylabel('Percentage')
  • title(name ' Drug Use')
  • Type the function definition in a text file
  • Save
  • ? SOURCE CODE

25
Comments
File plotdata.py Purpose A useful plotting
function Author Me
  • Annotate
  • Explain
  • Identify

26
Import Statement
Import Pylab from pylab import Import
Data from DrugData import
  • Load modules into interpreter memory
  • from ltMODULEgt import ltSOMETHINGgt
  • from DrugData import Marijuana

27
Strings
title(name ' Drug Use')
  • A list of characters
  • Indicated by 'ltSOMETHINGgt'
  • String concatenation 'a' 'b' ? 'ab'

28
Function Definition
  • Define the function
  • def plotData(data, name)
  • plot(Year, data)
  • show()
  • xlabel('Year')
  • ylabel('Percentage')
  • title(name ' Drug Use')
  • You can define more than function in a module

29
Running a Function from a Module
  • gtgtgt from plotData import
  • gtgtgt plotData(Heroin, 'Heroin')

30
Return Values
gtgtgt def average(data) function uses
average instead of mean return
mean(data)
  • Output
  • return ltSOMETHINGgt
  • Function exits immediately after executing

31
Module Syntax Indentation
  • gtgtgt def plotData()
  • plot(Year, Marijuana)
  • show()
  • xlabel('Year')
  • ylabel('Percentage')
  • title('Marijuana Drug Use')

File "ltpyshell7gt", line 3 show()
IndentationError unexpected indent
Write a Comment
User Comments (0)
About PowerShow.com