Title: Graphical Excellence
1Graphical Excellence
- CMSC 120 Visualizing Information
- 2/7/08 Lecture Part II
2Graphical 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
3Data
4Visualization
5Fate of Napoleons Army
Advance
Retreat
Temperature
6Principles 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
7A Matter of Substance and Statistics
- CMSC 120 Visualizing Information
- 2/7/08 Lecture Part II
8Data
9Samples 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
10Distribution
- Arrangement of the set of possible solutions
along a number line
11Statistical 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
12Relational Statistics
- Covariance spread of values in multiple
dimensions - Correlation how well one measure predicts another
13Pylab and Python Statistics
- mean(ltDATAgt)
- median(ltDATAgt)
- var(ltDATAgt)
- std(ltDATAgt)
- correlate(ltDATAgt)
- corrcoeff(ltDATAgt)
- cov(ltDATAgt)
14Sprechen de Python?
- CMSC 120 Visualizing Information
- 2/7/08 Lecture Part III
15Blocks 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
16Running a Function
gtgtgt plotData()
17Parameters
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')
-
18Parameters
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')
-
19Parameters
- gtgtgt plotData(Marijuana, 'Marijuana')
-
20Parameters
- gtgtgt plotData(Heroin, 'Heroin')
-
21Functions
- def ltFUNCTION NAMEgt (ltPARAMTERSgt)
- ltSOMETHINGgt
-
- ltSOMETHINGgt
22Running a Function
gtgtgt plotData()
- Traceback (most recent call last)
- File "ltpyshell5gt", line 1, in ltmodulegt
- plotData()
- NameError name 'plotData' is not defined
23Modules
- Type the function definition in a text file
- Save
- ? SOURCE CODE
24Modules
- 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
25Comments
File plotdata.py Purpose A useful plotting
function Author Me
- Annotate
- Explain
- Identify
26Import Statement
Import Pylab from pylab import Import
Data from DrugData import
- Load modules into interpreter memory
- from ltMODULEgt import ltSOMETHINGgt
- from DrugData import Marijuana
27Strings
title(name ' Drug Use')
- A list of characters
- Indicated by 'ltSOMETHINGgt'
- String concatenation 'a' 'b' ? 'ab'
28Function 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
29Running a Function from a Module
- gtgtgt from plotData import
- gtgtgt plotData(Heroin, 'Heroin')
-
30Return Values
gtgtgt def average(data) function uses
average instead of mean return
mean(data)
- Output
- return ltSOMETHINGgt
- Function exits immediately after executing
31Module 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