welcome to information literacy ii good morning
play

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:


  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

  2. Information Literacy II – EN(IL2) Course Lecture 2 – Chart with Matplotlib

  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

  4. Last week review (and more)

  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?

  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

  7. Other tools (no slides – only demo)

  8. Introduction to Python

  9. Python (again) Simple examples List Comprehensions numbers = [1, 2, 3, 4, 5, 6, 7] Create new lists easily squared = [x**2 for x in numbers] Can be used to modify data total = sum(numbers) percentage = [x/total*100 for x in numbers] Mini-exercise: # Input L = [104, 71, 234, 78, 9, 23] Given a list of numbers, create - a list containing the last digit of each elements # Output - a list containing the first digit of each elements last = [4, 1, 4, 8, 9, 3] first = [1, 7, 2, 7, 9, 2] Remark: the second question is HARD; please try but I do not expect you to be able to do it without help.

  10. Other type of charts

  11. Charts type Many types of charts: Line Chart Bar Chart Histogram Pie Chart Gantt Chart All images from Wikipedia. Need to know when/how to use each of them

  12. Bar Chart 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")

  13. Pie Chart Exercise (difficult): - Google “statistics tokyo tech” or find on 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)

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

Recommend


More recommend