Advanced
Searching inSummaries
How to search
  • Words find lesson titles, text and code. Filter by type (guides, courses, programs, books) or stay in this book.
  • book:rhcsa and ch:8 narrow the search; #code finds a word only in commands of the lessons.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

Course 8Name in the course: Data Visualization with Python: Hands-On Projects

Data Visualization with Python

Course 8 of 12 in the IBM Data Science certificate. How to make clear plots with Matplotlib.

Course page: Coursera

  • 8 Lessons
  • 0 Commands

$ run as a normal user# run as root (or with sudo)

8.1

What the course covers

How to make clear plots with Matplotlib.

  • How to pick the right chart for the data.
  • How to draw advanced plots: waffle charts, word clouds and Seaborn plots.
  • How to make maps and color maps with Folium.
  • How to build an interactive dashboard with Plotly and Dash.
  • A final project with real sales data and a timed exam.
ModuleMain focus
Module 1 · about 2 hoursIntroduction to Data Visualization Tools: why we plot, Matplotlib parts, line plots
Module 2 · about 3 hoursBasic and Specialized Visualization Tools: area, histogram, bar, pie, box, scatter
Module 3 · about 3 hoursAdvanced Visualizations and Geospatial Data: waffle, word cloud, Seaborn, Folium maps
Module 4 · about 5 hoursCreating Dashboards with Plotly and Dash: Plotly charts, Dash layout, callbacks
Module 5 · about 5 hoursFinal Project and Exam: automobile sales project, practice project, timed exam

8.2

Module 1: Introduction to Data Visualization Tools

Introduction to Data Visualization Tools: why we plot, Matplotlib parts, line plots.

  • A plot turns numbers into a picture. People see patterns faster.
  • Matplotlib is the main plotting library in Python. Seaborn and Plotly add features on top.
  • A Matplotlib figure has main parts: the Figure (the canvas) and the Axes (the plot area).
  • Basic steps: import matplotlib.pyplot as plt, then plt.plot(x, y), then plt.show().
  • A line plot is best for change over time: time on x, value on y.
  • Add a title, axis labels and a legend. A plot with no labels is hard to read.

8.3

Module 2: Basic and Specialized Visualization Tools

Basic and Specialized Visualization Tools: area, histogram, bar, pie, box, scatter.

  • Area plot: df.plot(kind="area"). It shows a total and its parts, stacked.
  • Histogram: plt.hist(data, bins=10). It shows how the values spread over bins.
  • Bar chart: kind="bar" for vertical bars, kind="barh" for horizontal bars.
  • Pie chart: plt.pie(values, labels=labels, autopct="%1.1f%%"). Use it for parts of one whole.
  • Box plot: the box runs from Q1 to Q3, the line inside is the median, and dots are outliers.
  • Scatter plot: two numbers, one on each axis. A bubble plot adds a third value as bubble size.

8.4

Module 3: Advanced Visualizations and Geospatial Data

Advanced Visualizations and Geospatial Data: waffle, word cloud, Seaborn, Folium maps.

  • A waffle chart is a grid of squares. It shows progress to a whole, like 40 of 100.
  • A word cloud shows words. A bigger word means the word is used more often.
  • Seaborn makes statistical plots fast: sns.regplot(), sns.boxplot(), sns.heatmap().
  • Folium makes interactive maps: folium.Map(location=[lat, lon], zoom_start=10).
  • A choropleth map colors regions by a value. It needs a GeoJSON file for the region shapes.

8.5

Module 4: Creating Dashboards with Plotly and Dash

Creating Dashboards with Plotly and Dash: Plotly charts, Dash layout, callbacks.

  • A dashboard puts the key numbers and charts on one screen.
  • Plotly makes interactive charts: hover to read values, zoom, and click. import plotly.express as px.
  • Dash builds a web app in Python: a layout (html.Div, dcc.Graph) and callbacks.
  • A callback links an input to an output: @app.callback(Output("chart", "figure"), Input("menu", "value")).
  • app.run(debug=True) starts the Dash app on your machine. Older labs use app.run_server.

8.6

Module 5: Final Project and Exam

Final Project and Exam: automobile sales project, practice project, timed exam.

  • The final project uses historical automobile sales data and compares recession with non-recession periods.
  • Deliverables: plots with Matplotlib, Seaborn and Folium, plus a dashboard with Plotly and Dash.
  • The practice project uses wildfire data in Australia. It is not graded.
  • The final exam is a timed quiz about the whole course.

8.7

Check yourself

Answer each question first, then open it to check the answer.

1Which library do you use for interactive maps in Python? a) Matplotlib · b) Folium · c) Dash · d) Seaborn

b) Folium. Folium draws maps that you can zoom and move.

2Which chart shows how values are spread over bins? a) Pie chart · b) Line chart · c) Histogram · d) Waffle chart

c) Histogram. A histogram puts values into bins and shows the count in each bin.

3In a box plot, what is the line inside the box? a) The maximum · b) The mean · c) The median · d) The minimum

c) The median. The box runs from Q1 to Q3; the line inside the box is the median.

4In a bubble plot, what does the bubble size show? a) The colour of the chart · b) The chart title · c) The number of rows · d) A third value for each point

d) A third value for each point. A third value sets the size of each bubble.

5Which argument sets the number of bins in plt.hist? a) bins= · b) kind= · c) color= · d) size=

a) bins=. bins= sets how many bins the histogram uses.

6What does a choropleth map do? a) Draws a line over time · b) Shows words by frequency · c) Colors regions by a value · d) Groups nearby markers

c) Colors regions by a value. A choropleth fills each region with a colour for its value.

7Which file does a Folium choropleth need for the region shapes? a) A CSV file · b) A GeoJSON file · c) A PNG image · d) An Excel file

b) A GeoJSON file. The shapes of the regions come from a GeoJSON file.

8What is a waffle chart good for? a) Showing parts of a whole as squares · b) Showing exact decimal values · c) Drawing a road map · d) Showing a trend line

a) Showing parts of a whole as squares. A waffle chart is a grid of squares that shows parts of a whole.

9Which library makes interactive charts with hover and zoom? a) Matplotlib · b) Pandas · c) Plotly · d) NumPy

c) Plotly. Plotly charts are interactive; Matplotlib charts are usually static.

10In Dash, what connects a dropdown to a chart? a) A callback · b) A markdown cell · c) A GeoJSON file · d) A box plot

a) A callback. A callback updates the output when the input changes.

11Which Dash component shows a Plotly figure on the page? a) html.Div · b) dcc.Graph · c) dcc.Dropdown · d) html.H1

b) dcc.Graph. dcc.Graph holds a Plotly figure in a Dash layout.

12Why do we add a title and axis labels to a plot? a) To make the file larger · b) To hide the data · c) To change the data type · d) To help the reader understand the plot

d) To help the reader understand the plot. Labels tell the reader what the axes and the plot mean.

8.8

Study and exam tips

Know which chart answers which question: line for time, histogram for spread, scatter for two numbers, map for places.

  • Remember the small details: bins=, autopct, kind="barh", and the median line in a box plot.
  • For Dash, learn the three parts: layout, dcc.Graph, and a callback.
  • Read every question twice. Many options are close, so look for the exact word.