I am trying to make a grouped bar chart with errors in matplotlib. The range in the values of y-axis is high and because of that the lower values are under-represented. So I want to make plot the graph with broken y-axis. Here is my code:
import matplotlib.pyplot as plt
import pylab as plt
import numpy as np
import matplotlib as mpl
import pandas as pd
from matplotlib.ticker import NullFormatter
from brokenaxes import brokenaxes
import matplotlib.pyplot as plt
# data to plot
n_groups = 5
plate1 = (2171.30445, 586.0188957, 686.3897089, 1634.08957, 8957.462436)
p1err = (277.796406, 60.74243945, 120.8867298, 232.1931229, 2695.236328)
plate2 = (1924.896604, 626.690557, 430.6515416, 1151.967586, 8040.870352)
p2err = (1672.937164, 194.6229754, 30.06731907, 639.8138954, 903.9350561)
index = np.arange(n_groups)
bar_width = 0.25
opacity = 0.8
error_config = {'ecolor': '0.3'}
rects1 = plt.bar(index, plate1, bar_width,
alpha=opacity,
color='b',
yerr=p1err,
capsize=10,
error_kw=error_config,
label='Plate 1')
rects2 = plt.bar(index + bar_width, plate2, bar_width,
alpha=opacity,
color='r',
yerr=p2err,
capsize=10,
error_kw=error_config,
label='Plate 2')
plt.xticks(index + bar_width, ('C1T25-C1T18', 'C1T25-C1T18c', 'C1NT25-C1T18', 'C1NT25-C1T18c'))
a) I want to break the y-axis between 4000 and 8000.
b) I also want to rotate the xticks to 45 degree so as to accommodate additional data.
I am attaching the final graph I made in excel as a screengrab (note: this is without the broken y-axis) https://www.dropbox.com/s/967jmbnzl4tibkx/Picture1.png?dl=0