Welcome to Information Literacy II Good morning! Lecture will start - - PowerPoint PPT Presentation

welcome to information literacy ii good morning
SMART_READER_LITE
LIVE PREVIEW

Welcome to Information Literacy II Good morning! Lecture will start - - PowerPoint PPT Presentation

Welcome to Information Literacy II Good morning! Lecture will start at 10:45 (let's wait for everyone). If you have any question, please ask in the chat. Note that lecture will be recorded. Please write your name there:


slide-1
SLIDE 1

Welcome to Information Literacy II Good morning!

  • Lecture will start at 10:45 (let's wait for everyone).
  • If you have any question, please ask in the chat.
  • Note that lecture will be recorded.
  • Please write your name there:

https://forms.gle/YoUb9zT7Q2sX9WSD7

slide-2
SLIDE 2

Lecture 2 – Chart with Matplotlib

Information Literacy II – EN(IL2) Course

slide-3
SLIDE 3

Today's schedule

Review of last week Overview of other tools

Microsoft Excel Google Sheets

Introduction to Python (cont'd) Other type of graphs

slide-4
SLIDE 4

Last week review (and more)

slide-5
SLIDE 5

Saving chart to file

Use plt.savefig(filename) File type is decided by extension: figure.pdf or figure.png or figure.jpg or …

Mini-exercise: Save the same plot using .pdf and .png Do you see any difference? What are the advantages/drawbacks of these formats?

slide-6
SLIDE 6

Comparing .pdf or .png

Both are portable: readable on (almost) all computers Pdf files can contain vector graphics Png files contain only raster graphics Possible to zoom with pdf files, but potentially larger files for complex plot (e.g. with many points) Both formats can be used in LaTeX

slide-7
SLIDE 7

Other tools (no slides – only demo)

slide-8
SLIDE 8

Introduction to Python

slide-9
SLIDE 9

Python (again)

List Comprehensions Create new lists easily Can be used to modify data Simple examples numbers = [1, 2, 3, 4, 5, 6, 7] squared = [x**2 for x in numbers] total = sum(numbers) percentage = [x/total*100 for x in numbers]

Mini-exercise: Given a list of numbers, create

  • a list containing the last digit of each elements
  • a list containing the first digit of each elements

Remark: the second question is HARD; please try but I do not expect you to be able to do it without help.

# Input L = [104, 71, 234, 78, 9, 23] # Output last = [4, 1, 4, 8, 9, 3] first = [1, 7, 2, 7, 9, 2]

slide-10
SLIDE 10

Other type of charts

slide-11
SLIDE 11

Charts type

Many types of charts:

Line Chart Bar Chart Histogram Pie Chart Gantt Chart

Need to know when/how to use each of them

All images from Wikipedia.

slide-12
SLIDE 12

foreignBStudents = [173, 172, 194, 248, 276, 294, 307, 282, 267, 252, 238, 220, 187, 170, 174, 186, 210, 239, 249, 267] years = list(range(2000, 2020)) # Axis labels and graph title plt.xlabel("Academic year") plt.ylabel("Number of students") plt.title("Number of undegraduate foreign students in Titech") # Small modifications of axis plt.xticks([2000, 2005, 2010, 2015, 2019]) plt.ylim(0, 320)

# Only this line change compared to before! plt.bar(years, foreignBStudents)

# Save the generated graph to file plt.savefig("BStudentsTokyTech.png")

Bar Chart

slide-13
SLIDE 13

Pie Chart

Exercise (difficult):

  • Google “statistics tokyo tech” or find
  • n Tokyo Tech website
  • Look for information on how to draw

pie charts

  • Draw a graph similar to the one on

the right (It may be difficult to display the percentage values)

slide-14
SLIDE 14

plt.pie() creates the pie chart It takes the sizes of each slice and the labels Find how to add the percentage values by yourself  Look for examples online. Impossible to guess. Use plt.axis(‘equal’) to have a circular pie Try without this line and see the result names = ['Science', 'Engineering', 'Ma terials', 'Computing', 'Life', 'Enviro nment'] sizes = [151, 358, 183, 92, 150, 134] plt.pie(sizes, labels=names) plt.axis('equal') plt.title('Admission quota (AY2016)') plt.savefig("quota.png")

Pie Chart