Compare your results for the pre-task assignment with your team members
Task 0. Run each member’s code and compare results with the given
solutions. Discuss the differences and similarities of your approaches, highlighting
strengths of each.
Enhance the chosen team member’s pre-class activity code file with the following
improvements:
Modify your figure to use the twinx() function to create a single plot with
two y-axes instead of side-by-side subplots:
Shared x-axis: Time (days)
Left y-axis: Price (USD) — plot as a blue line with circle markers
Right y-axis: Volume (USD) — plot as a red bar chart
Note
You can refer to the matplotlib documentation on twinx() found
here.
Adjust the plot settings for visibility:
Set the bar chart’s transparency to 0.2 (20% opacity).
Set the y-axis limits for Volume to range from 0 to 3 times the maximum volume.
This ensures the bars stay in the bottom third of the graph.
Place the Price legend in the upper left and the Volume legend in the upper right.
Ensure that your plot matches the sample output below.
When calculating the Volume, use list comprehension instead of a for loop using the
zip() function to iterate through the Quantity and Price lists
simultaneously.
Note
List comprehensions are a more “Pythonic” way to create lists and can often lead to
more concise and readable code. You can find examples of list comprehensions in the
official Python
tutorial.
When complete, save the modified file as
py4_team_1_teamnumber.py and turn it in
with the remainder of the team task assignment files in Gradescope.