[SOLVED] COMP1007 Assignment5-fundamental operations of Matplotlib

35.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

This assignment helps you review the fundamental operations of Matplotlib (covered by our labs) and self-learn some new features (not covered by our labs). Please store all your solutions in a single Python file. Use a separate cell for each question.

  1. Write a Python program that generates the following figure with 4 subplots, each with a differentmarker style.

Hint: when you call the scatter() function, set the marker parameter to ‘+’, ‘x’, 4, and 5 respectively, for the four different marker style. E.g., axes.scatter(x, y, marker=’+’).

Marker reference: https://matplotlib.org/api/markers_api.html#module-matplotlib.markers

  1. Assume a dictionary books = {‘Tom’:10, ‘Dick’:11, ‘Harry’:9, ‘Slim’:7, ‘Jim’:12} stores the number of books of five students. Write a Python program that generates the following figure.

Hint:

  • to get the list of dictionary values, you can use list(books.values());
  • to get the list of dictionary keys (as the y-axis labels), you can use list(books);
  • to set the y-axis ticks and labels, use function set_yticks() and set_yticklabels(). You can learn from the following online example to set the y-axis labels correctly:

https://matplotlib.org/gallery/lines_bars_and_markers/barh.html

  1. Study the example at https://matplotlib.org/gallery/lines_bars_and_markers/simple_plot.html. Then write a Python program that generates the following figure with 2 subplots.

Hint: you may need to use the tight_layout() function to set a tight layout.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.