Make the top, right subplot active in the current 2×2 subplot grid and plot the % of degrees awarded to women in Computer Science in red in the active subplot.Create a figure with 2×2 subplot layout, make the top, left subplot active, and plot the % of degrees awarded to women in Physical Sciences in blue in the active subplot.Here, you will make a 2×2 grid of subplots and plot the percentage of degrees awarded to women in Physical Sciences (using physical_sciences), in Computer Science (using computer_science), in Health Professions (using health), and in Education (using education). Now you have some familiarity with plt.subplot(), you can use it to plot more plots in larger grids of subplots of the same figure. Plot the percentage of degrees awarded to women in Computer Science in red in the active subplot.Use plt.subplot() again to make the second subplot active in the current 1x2 subplot grid.Plot the percentage of degrees awarded to women in Physical Sciences in blue in the active subplot.Use plt.subplot() to create a figure with 1x2 subplot layout & make the first subplot active.Rather than using plt.axes() to explicitly lay out the axes, you will use plt.subplot(m, n, k) to make the subplot grid of dimensions m by n and to make the kth subplot active (subplots are numbered starting from 1 row-wise from the top left corner of the subplot grid). In this exercise, you will continue working with the same arrays from the previous exercises: year, physical_sciences, and computer_science. A better alternative is to use plt.subplot() to determine the layout automatically. The command plt.axes() requires a lot of effort to use well because the coordinates of the axes need to be set manually. Plot the percentage of degrees awarded to women in Computer Science in red in the active axes just created.Create a set of plot axes with lower corner xlo and ylo of 0.525 and 0.05, width of 0.425, and height of 0.9 (in units relative to the figure dimension). Plot the percentage of degrees awarded to women in Physical Sciences in blue in the active axes just created.Note: Remember to pass these coordinates to plt.axes() in the form of a list.Create a set of plot axes with lower corner xlo and ylo of 0.05 and 0.05, width of 0.425, and height of 0.9 (in units relative to the figure dimension).After issuing a plt.axes() command, plots generated are put in that set of axes. The coordinates and lengths are values between 0 and 1 representing lengths relative to the dimensions of the figure. Note that these coordinates can be passed to plt.axes() in the form of a list or a tuple. In calling plt.axes(), a set of axes is created and made active with lower corner at coordinates (xlo, ylo) of the specified width and height. You will use plt.axes() to create separate sets of axes in which you will draw each line plot. Here, you have the same three arrays year, physical_sciences, and computer_science representing percentages of degrees awarded to women over a range of years. The command plt.axes() is one way to do this (but it requires specifying coordinates relative to the size of the figure). Rather than overlaying line plots on common axes, you may prefer to plot different line plots on distinct axes. Use plt.show() to display the figure with the curves on the same axes.Add a 'red' line plot of the % of degrees awarded to women in Computer Science ( computer_science) from 1970 to 2011 ( year).Note that the x-axis should be specified first. Add a 'blue' line plot of the % of degrees awarded to women in the Physical Sciences ( physical_sciences) from 1970 to 2011 ( year).Import matplotlib.pyplot as its usual alias.Here, year represents the x-axis, while physical_sciences and computer_science are the y-axes. You will issue two plt.plot() commands to draw line plots of different colors on the same set of axes. Here, three NumPy arrays have been pre-loaded for you: year (enumerating years from 1970 to 2011 inclusive), physical_sciences (representing the percentage of Physical Sciences degrees awarded to women each in corresponding year), and computer_science (representing the percentage of Computer Science degrees awarded to women in each corresponding year). You can compare trends in degrees most easily by viewing two curves on the same set of axes. The data set here comes from records of undergraduate degrees awarded to women in a variety of fields from 1970 to 2011. It is time now to put together some of what you have learned and combine line plots on a common set of axes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |