Lecture 27 Plotting II

In this lecture, we will learn:
1)
Error Bars
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 out well.


The 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 used.

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:


The saved image will appear in the same directory as you .py file, I zoomed-in the image, the resolution is good enough for publications/presentations.


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 list.


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:




Tasks:

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.