Getting to know the layout attribute
For the current figure that we are working on, let's add a title (for the whole figure), along with axis titles, to see how it works:
fig.layout.title = 'The Figure Title' fig.layout.xaxis.title = 'The X-axis title' fig.layout.yaxis.title = 'The Y-axis title'
As you can see, we are exploring the tree-like structure of our figure. There is a title
attribute that falls directly under fig.layout
, and there are also titles for fig.layout.xaxis
and fig.layout.yaxis
. To give you a sense of how detailed the available options are, Figure 3.3 shows some of the xaxis
attributes that start with tick
only:

Figure 3.3 – Some of the Figure object's layout.xaxis options
Let's now look at the effect of the four lines of code we just added:

Figure 3.4 – The updated figure containing two traces, a legend, and titles
The three titles we have...