How it works...

After importing the module, the data is presented in step 2 from the How to do it… section in a convenient way, which will likely be similar to the way the data was originally stored.

Because of the way matplotlib works, it requires an X component as well as a Y component. In this case, our X component is just a sequence of integers, as many as data points. We create that in POS. In VALUES, we store the numeric value of the sales as a sequence, and in LABELS the associated label for each data point. All that preparation work is done in step 3.

Step 4 creates the bar graph, with the sequences X (POS) and Y (VALUES). These define our bars. To specify the period it refers to, we put labels on the x axis for each value with .xticks in the same way. To clarify the meaning, we add a label with .ylabel.

To display the resulting  graph, step 5 calls .show, which opens a new window with the result.

Calling .show blocks the execution of the program. The program will resume when the window is closed.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.198.154