Fixed errorbar plots in gh chapter.

I changed the ZZy-axis earlier, which meant that the bar for
sensor A was not visible.
This commit is contained in:
Roger Labbe 2015-11-25 12:00:38 -08:00
parent fe79d7409f
commit 6f6108780c
3 changed files with 31 additions and 30 deletions

File diff suppressed because one or more lines are too long

View File

@ -20,14 +20,14 @@ from __future__ import (absolute_import, division, print_function,
import matplotlib.pyplot as plt
import numpy as np
def plot_errorbars(bars, xlims):
def plot_errorbars(bars, xlims, ylims=(0, 2)):
i = 0.0
for bar in bars:
plt.errorbar([bar[0]], [i], xerr=[bar[1]], fmt='o', label=bar[2] , capthick=2, capsize=10)
i += 0.2
plt.ylim(0, 2)
plt.ylim(*ylims)
plt.xlim(xlims[0], xlims[1])
show_legend()
plt.gca().axes.yaxis.set_ticks([])

View File

@ -25,16 +25,17 @@ import pylab as plt
def plot_errorbar1():
with book_format.figsize(y=1.5):
book_plots.plot_errorbars([(160, 8, 'A'), (170, 8, 'B')],
xlims=(145, 185))
xlims=(145, 185), ylims=(-1, 2))
def plot_errorbar2():
with book_format.figsize(y=1.5):
book_plots.plot_errorbars([(160, 3, 'A'), (170, 9, 'B')],
xlims=(145, 185))
xlims=(145, 185), ylims=(-1, 2))
def plot_errorbar3():
with book_format.figsize(y=1.5):
book_plots.plot_errorbars([(160, 1, 'A'), (170, 9, 'B')], xlims=(145, 185))
book_plots.plot_errorbars([(160, 1, 'A'), (170, 9, 'B')],
xlims=(145, 185), ylims=(-1, 2))