In this lecture, we will learn:
2) The Bar Chart
1. Error bars
Let's add some error bars to the line data figure first:
Oops! The legend is not showing the entire text...
However, if I put the legend text into a 'list' or a 'tuple', it works
reason is you are expected to pass in an iterable of strings, but you
pass in just one string. A string is an iterable of strings too (it
yields individual characters), which is why only the first character is
The line and the error bar is not that nice. Let's modify it:
Wow! This looks much nicer, close to the publishable quality.
Need a better resolution for the figure? Try this:
saved image will appear in the same directory as you .py file, I
zoomed-in the image, the resolution is good enough for
2. The Bar Chart
Let's plot a simplest bar chart first:
The X ticks can be changed to other texts easily by changing the X
Add error bars to them:
Grouped bar chart:
Try to remove the underlined contents in the figure above and you'll
see why we have them there.
The figure plotted is snipped separated:
1. Plot the following data (you can download the data here).
in a line chart and in a bar chart respectively. Make sure they have
the error bars and appropriate labels, titles, font size, etc in both
of the two plots.
2. Plot the following data in a bar chart (you can download the data here). Make sure they have the error bars and appropriate labels, titles, font size, etc in both of the two plots.