Table of Contents

  1. How to modify graphics

  2. How to modify animations

  3. Overview of steps to get the data

  4. Button creation to run functions

  5. Supporting functions

Direct questions to

How to modify graphics

The function create_graphic is the main function used to create the graphics with options.

There is a button below it (Create Graphic) that will call this function and create the graphic. To use this button, all the cells in the notebook must be run first and then the button will appear and it can be clicked to create the graphic which is displayed.

After the graphic is created, the png and pdf file versions can be downloaded with the download button (Download Graphic Files) which was created when all the notebook cells were run.

Plot options to configure

Titles, inset text, and plot labels can be modified for content, font properties and placement.

Plot ticks can be modified in the number created, spacing, length and thickness and the tick numbers can be formatted with font properties and modified to change how close they are to the axes.

Functions to make these changes are:

set_matplotlib_properties sets axes line width, font properties,

set_plot_props sets tick and label properties and axes limits

create_xtick_labels Function used for some plots and it changes decimal dates into date text and changes the positions of tick labels.

add_plot_title Sets the placement of any plot titles of the plot and their font properties. Titles as function arguments can be blank strings and then they won't show up. The function can be modified to use only one title or more than two. In the function 'set_plot_props', the spacing above the axes bounds of the plot used to give space for any titles can be adjusted by changing the 'top' property.

add_inset_label Sets the placement of text displayed within the plot axes bounds and sets their font properties.

add_legend_labels Sets the placement of legends and their font properties.

add_sio_logo Sets the placement, resolution and size of the sio logo.

Plot axes

Modify modify axes thickness and whether they appear on the plot. This is done by modifying rcParams in the set_matplotlib_properties function. As an example, to remove the top and right axis, add the following:

plt.rcParams[""] = False

plt.rcParams["axes.spines.right"] = False

Plot colors

The dots, line, and gradient colors can be modified.

gradient_fill Sets properties of the gradient under the plot line. This is a guide to the eye.

Resolution and size of the graphic

save_graphic Modify the resolution and size of the png file of the graphic.

Time range

The time range and CO2 concentration range can be varied by changing the values of xmin, xmax, ymin, ymax.

Set plot features to add

create_graphic The titles, gradient, inset text, legend and logo can be changed and included or excluded from the graphic.

Go to table of contents

How to modify animations

See the above section to set the graphic settings

To reduce the time of the animation creation

For all animations, the gradient is not included in the animations because it would increasee the time to create the animation.

Create an animation with less features than the graphic can be configured with. This is called a bare animation.

create_animation_bare Removes titles, descriptive text, and sio logo and set the resolution to 72dpi. The size of the animation can be changed from the default 10 inches wide.

The bare animation takes about 2 minutes on a local computer and about 4 minutes using Google Colab to create at frames per second = 60 and dpi=72

Create an animation with more plot features but with a longer creation time

create_animation Adds titles, descriptive text, and sio logo to create at frames per second = 60 and dpi=72

Animation width

The animation width is set at 10 inches, and if changed, the graph properties have to be modified so that they scale appropriately. This example code is not given.

Testing the animation settings

Use a smaller number of frames and/or increase the frame interval and/or change the frames per second, fps. Uncomment the testing code, comment the current creation code, and change comments back when you are done testing.

Go to table of contents

Overview of steps to get the data

At the beginning of each notebook, data is downloaded from the keeling curve GitHub repository and from web links.

The data is processed so that it can be imported into Pandas dataframes. This makes it easier to modify the data, such as choosing the time range and variables to plot. And then the dataframes are output as decimals to use in creating the plot.

Button creation to run functions

Buttons are created when the cell is run. It uses widgets to create the button and its properties

To learn more about widgets, see

Supporting functions to the main graphics functions

There are supporting functions in some notebooks to convert date and time formats

dt2t Function to convert a datetime to a float

t2dt Function to convert a float to a datetime

get_todays_date_variations Function to create various date versions for today's date

get_data_end_date Function to get the end date of data

Go to table of contents