本文整理汇总了Python中matplotlib.gridspec.GridSpec类的典型用法代码示例。如果您正苦于以下问题:Python GridSpec类的具体用法?Python GridSpec怎么用?Python GridSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GridSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_stereo_rose
def get_stereo_rose(self):
"""
Resets the figure and returns a stereonet and rose diagram axis.
When the view in the main window is changed to stereonet and rose
diagram, the figure is reset. The current settings are applied and
two subplots for the stereonet and rose diagram are created. The
axis of the stereonet and rose diagram are returned. This method is
called by the MainWindow "redraw_plot"-method.
"""
self.fig.clf()
self.fig.patch.set_facecolor(self.props["canvas_color"])
self.fig.set_dpi(self.props["pixel_density"])
gridspec = GridSpec(2, 5)
sp_stereo = gridspec.new_subplotspec((0, 0),
rowspan=2, colspan=2)
sp_cbar = gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
sp_rose = gridspec.new_subplotspec((0, 3),
rowspan=2, colspan=2)
ax_stereo = self.fig.add_subplot(sp_stereo,
projection=self.get_projection())
ax_rose = self.fig.add_subplot(sp_rose, projection="northpolar")
ax_cbar = self.fig.add_subplot(sp_cbar)
ax_cbar.axis("off")
ax_cbar.set_aspect(8)
return ax_stereo, ax_rose, ax_cbar
示例2: plot_fd
def plot_fd(fd_file, fd_radius, mean_fd_dist=None, figsize=DINA4_LANDSCAPE):
fd_power = _calc_fd(fd_file, fd_radius)
fig = plt.Figure(figsize=figsize)
FigureCanvas(fig)
if mean_fd_dist:
grid = GridSpec(2, 4)
else:
grid = GridSpec(1, 2, width_ratios=[3, 1])
grid.update(hspace=1.0, right=0.95, left=0.1, bottom=0.2)
ax = fig.add_subplot(grid[0, :-1])
ax.plot(fd_power)
ax.set_xlim((0, len(fd_power)))
ax.set_ylabel("Frame Displacement [mm]")
ax.set_xlabel("Frame number")
ylim = ax.get_ylim()
ax = fig.add_subplot(grid[0, -1])
sns.distplot(fd_power, vertical=True, ax=ax)
ax.set_ylim(ylim)
if mean_fd_dist:
ax = fig.add_subplot(grid[1, :])
sns.distplot(mean_fd_dist, ax=ax)
ax.set_xlabel("Mean Frame Displacement (over all subjects) [mm]")
mean_fd = fd_power.mean()
label = r'$\overline{{\text{{FD}}}}$ = {0:g}'.format(mean_fd)
plot_vline(mean_fd, label, ax=ax)
return fig
示例3: nbo_vs_year
def nbo_vs_year(self):
"""
Plot percent of structures, with different NBO per 1000 atoms levels,
from "good" pdb structures (all PDB files with a single model, no unknown
atom types and good CRYST1 records) VS. year
Second sub plot: the total of "good" structures deposited VS. year
"""
plt.close('all')
# figure parameters
# plt.ion() # enables interactive mode
max_y = 105
fontsize = 20
fig = plt.figure(figsize=(8,10))
gs = GridSpec(2,1,height_ratios=[2,1])
# first subplot
ax1 = plt.subplot(gs[0,0])
ax2 = plt.subplot(gs[1,0])
lines = []
line_type = ['.:','.-','.--']
n = len(line_type)
for i,pd in enumerate(self.plot_data_list):
lt = line_type[i%n]
l, = ax1.plot(pd.years,pd.percent,lt)
lines.append(l)
ax1.set_ylabel('Percent of PDB structures',fontsize=fontsize)
ax1.text(min(self.years)+0.5,max_y-4,'a.',fontsize=fontsize)
ax1.tick_params(axis='both',labelsize=fontsize - 2)
ax1.axes.get_xaxis().set_visible(False)
ax1.set_yticks([5,10,40,70,100])
ax1.set_ylim([0,max_y])
ax1.set_xlim([self.start_year,self.end_year])
# legend
labels = ['NBO per 1000 atom > {}']*len(self.nbo_per_1000_atoms)
labels = [x.format(y) for x,y in zip(labels,self.nbo_per_1000_atoms)]
if self.sym:
legend_pos = [0.96,0.70]
else:
legend_pos = [0.54,0.30]
ax1.legend(
lines,labels,
bbox_to_anchor=legend_pos,
loc=1,borderaxespad=0.0)
# Second subplot
ax2.plot(self.years,self.n_total,'.:g')
ax2.set_xlim([self.start_year,self.end_year])
ax2.set_xlabel('Year',fontsize=fontsize)
ax2.set_ylabel('Number of structures',fontsize=fontsize)
ax2.text(min(self.years)+0.5,max(self.n_total)-5,'b.',fontsize=fontsize)
ax2.tick_params(axis='both',labelsize=fontsize - 2)
ax2.set_xticks([self.start_year,1990,2000,self.end_year])
ax2.set_yscale('log')
ax2.set_yticks([10,100,1000])
#
gs.tight_layout(fig)
gs.update(hspace=0)
s = 'all'*(not self.sym) + 'sym'*self.sym
fig_name = 'nbo_vs_year_{}.png'.format(s)
plt.savefig(fig_name)
fig.show()
示例4: create_canvas
def create_canvas(self): # pragma: no cover
self.fig = Figure()
canvas = FigureCanvas(self.fig)
self.ui.mainLayout.addWidget(canvas)
canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
# Add subplots
gridspec = GridSpec(2, 4)
self.map_ax = self.fig.add_subplot(
gridspec.new_subplotspec((0, 0), rowspan=2, colspan=2)
)
self.spectrum_ax = self.fig.add_subplot(
gridspec.new_subplotspec((0, 2), rowspan=1, colspan=2)
)
self.hist_ax = self.fig.add_subplot(
gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
)
self.edge_ax = self.fig.add_subplot(
gridspec.new_subplotspec((1, 3), rowspan=1, colspan=1)
)
# Create the colorbar on the histogram axes
self.cbar = plots.draw_histogram_colorbar(ax=self.hist_ax,
cmap="viridis",
norm=Normalize(0, 1))
self.cbar.ax.set_xlabel("Map Value")
# Adjust the margins
self.fig.tight_layout(pad=0)
self.fig.canvas.draw_idle()
示例5: main
def main():
matplotlib.rc('font', size=12)
fig = plt.figure(figsize=(16,9))
gs = GridSpec(2, 1, height_ratios=[20, 1])#, 20])
gs.update(hspace=0., wspace=0.)
ax1 = plt.subplot(gs[0])
label_ax = plt.subplot(gs[1])
[ax.set_xlim(0, 599) for ax in (ax1, label_ax)]
ax1.set_ylim(0, 350)
# New way
regiondict = dict(zip(range(1,600), ['MA']*(133-1) + ['CA']*(364-133) + ['p2']*(378-364) + ['NC']*(433-378) + ['p1']*(449-433) + ['p6']*(501-449) + ['PR']*(600-501)))
N_lines = 50
muts = get_muts('gag-gag') + get_muts('gag-pr')
muts = [mut for mut in muts if regiondict[mut[1]] != regiondict[mut[0]]]
muts.sort(key=lambda x: x[-1], reverse=True)
min_mi = muts[N_lines-1][2]
counter = 0
for mut in muts[:N_lines]:
r1, r2 = regiondict[mut[0]], regiondict[mut[1]]
c = 'r' if r2 == 'PR' else 'b'
ax1.add_patch(make_circ(*mut, ec=c))
counter += 1
print counter
r = range(1)
proxy1 = plt.Line2D(r, r, color='b', markerfacecolor='none', lw=3)
proxy2 = plt.Line2D(r, r, color='r', markerfacecolor='none', lw=3)
ax1.legend((proxy1, proxy2), ('Gag-Gag', 'Gag-PR'))
# Add x-axis boxes
locs = [(132, 'MA'), (363, 'CA'), (377, 'p2'), (432, 'NC'), (448, 'p1'), (500, 'p6'),
(599, 'PR')]
x_start = 0
colors = ('#AAAAAA', '#EEEEEE')
for i, (junc, name) in enumerate(locs):
color = colors[i%2]
width = junc - x_start
rect = patches.Rectangle((x_start, 0), width, 1, color=color)
label_ax.add_patch(rect)
label_ax.text(x_start + width/2., 1/2., name, ha='center', va='center')
x_start = junc
label_ax.set_xlim(0, 599)
label_ax.set_xticks([1]+range(50, 650, 50))
label_ax.set_xticklabels([1]+range(50, 500, 50)+[1]+range(50, 150, 50))
[plt.setp(ax.get_xticklabels(), visible=False) for ax in (ax1, )]
[plt.setp(ax.get_yticklabels(), visible=False) for ax in (ax1, label_ax)]
[ax.tick_params(top=False, left=False, right=False, bottom=False) for ax in (ax1, label_ax)]
ax1.tick_params(bottom=True)
ax1.set_xticks(np.arange(0, 599, 10))
label_ax.set_xlabel('Sequence position')
plt.show()
示例6: initialize_figure
def initialize_figure(start_hour, stop_hour):
f = plt.figure(figsize=(17, 21))
font_1 = font_0.copy()
font_1.set_size('20')
font_1.set_weight('bold')
plt.suptitle(u"Schemat wyznaczania HRA dla pojedynczego 24-godzinnego nagrania odstępów RR.",
fontproperties=font_1, y=0.995, fontsize=25)
empty_ratio = 0.2
height_ratios = [
0.5, #1 24-tachogram
0.3, #2 plot 24h -> 2h pass
0.9, #3 2-hour tachogram
empty_ratio, #4 empty
0.45, #5 5-min window arrow plot
#empty_ratio, #6
0.9, #7 2-hour windowed tachogram
empty_ratio, #8 empty plot
0.55, #9 calculate descriptors arrow plot
empty_ratio, #10 empty plot
0.9, #11 2-hour windowed tachogram with asymmetry signs
2.0 #12 schema for binomial test
]
num_rows = len(height_ratios)
num_cols = 1
row_number = 0
gs1 = GridSpec(num_rows, num_cols, height_ratios=height_ratios) #[3, 0.3, 3, 0.5, 4])
gs1.update(left=0.04, right=0.99, wspace=0.1, hspace=0.0, bottom=0.04, top=0.98)
return f, gs1
示例7: plot_ext_laws
def plot_ext_laws(self):
wave = np.arange(900, 20000)
f0 = np.ones(wave.shape[0])
for law in ['calz', 'ccm', 'allen', 'prevot', 'seaton', 'fitz']:
getattr(self, law)(wave, f0, 1.)
self.wild(wave)
fig = plt.figure()
gs = GridSpec(1,1)
gs.update(left=0.12, right=0.95, top=0.95, bottom=0.12)
ax = fig.add_subplot(gs[0])
ax.semilogx(wave, self.calz_klam, 'c', lw=1.5, label='Calzetti')
# ax.semilogx(wave, self.ccm_klam, 'k', label='Cardelli')
ax.semilogx(wave, self.allen_klam, 'r', lw=1.5, label='Allen')
ax.semilogx(wave, self.prevot_klam, 'g', lw=1.5, label='Prevot')
ax.semilogx(wave, self.seaton_klam, 'm', lw=1.5, label='Seaton')
ax.semilogx(wave, self.fitz_klam, 'b', lw=1.5, label='Fitzpatrick')
ax.legend(frameon=False)
for axis in ['top', 'bottom', 'left', 'right']:
ax.spines[axis].set_linewidth(1.5)
ax.set_ylabel(r'$k(\lambda)$', fontsize=20)
ax.set_xlabel(r'$\lambda [\AA]$', fontsize=20)
ax.set_xlim(9e2, 2.5e4)
ax.set_ylim(0, 20)
plt.savefig('extlaw.pdf')
示例8: create_canvas
def create_canvas(self):
# Add the canvas to the UI
self.fig = Figure()
canvas = FigureCanvas(self.fig)
self.ui.mainLayout.addWidget(canvas)
# Add subplots
gridspec = GridSpec(2, 4)
self.img_ax = self.fig.add_subplot(
gridspec.new_subplotspec((0, 0), rowspan=2, colspan=2)
)
self.spectrum_ax = self.fig.add_subplot(
gridspec.new_subplotspec((0, 2), rowspan=1, colspan=2)
)
self.hist_ax = self.fig.add_subplot(
gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
)
self.edge_ax = self.fig.add_subplot(
gridspec.new_subplotspec((1, 3), rowspan=1, colspan=1)
)
# Create the colorbar on the histogram axes
self.cbar = plots.draw_histogram_colorbar(ax=self.hist_ax,
cmap="viridis",
norm=Normalize(0, 1))
self.cbar.ax.set_xlabel("Intensity")
# Adjust the margins
self.fig.tight_layout(pad=0)
self.fig.canvas.draw_idle()
示例9: get_stereo_two_rose
def get_stereo_two_rose(self):
"""
Resets the figure and returns a stereonet two rose diagrams axis.
When the view in the main window is changed to this setting, this
function is called and sets up a plot with a stereonet and two
rose diagram axis. One axis is for azimuth, the other one for
dip.
"""
self.fig.clf()
self.fig.patch.set_facecolor(self.props["canvas_color"])
self.fig.set_dpi(self.props["pixel_density"])
gridspec = GridSpec(2, 4)
sp_stereo = gridspec.new_subplotspec((0, 0),
rowspan=2, colspan=2)
sp_cbar = gridspec.new_subplotspec((1, 2), rowspan=1, colspan=1)
sp_rose = gridspec.new_subplotspec((0, 3),
rowspan=1, colspan=1)
sp_drose = gridspec.new_subplotspec((1, 3),
rowspan=1, colspan=1)
ax_stereo = self.fig.add_subplot(sp_stereo,
projection=self.get_projection())
ax_rose = self.fig.add_subplot(sp_rose, projection="northpolar")
ax_drose = self.fig.add_subplot(sp_drose, projection="dippolar")
ax_cbar = self.fig.add_subplot(sp_cbar)
ax_cbar.axis("off")
ax_cbar.set_aspect(8)
return ax_stereo, ax_rose, ax_drose, ax_cbar
示例10: __init__
def __init__(self, main_window, settings, data, add_layer_dataset, add_feature, redraw_main):
"""
Initializes the RotationDialog class.
Requires the main_window object, the settings object (PlotSettings
class) and the data rows to initialize. All the necessary widgets are
loaded from the Glade file. A matplotlib figure is set up and added
to the scrolledwindow. Two axes are set up that show the original and
rotated data.
"""
self.builder = Gtk.Builder()
self.builder.set_translation_domain(i18n().get_ts_domain())
script_dir = os.path.dirname(__file__)
rel_path = "gui_layout.glade"
abs_path = os.path.join(script_dir, rel_path)
self.builder.add_objects_from_file(abs_path,
("dialog_rotation", "adjustment_rotation_dipdir",
"adjustment_rotation_dip", "adjustment_rotation_angle"))
self.dialog = self.builder.get_object("dialog_rotation")
self.dialog.set_transient_for(main_window)
self.settings = settings
self.data = data
self.trans = self.settings.get_transform()
self.add_layer_dataset = add_layer_dataset
self.add_feature = add_feature
self.redraw_main = redraw_main
self.adjustment_rotation_dipdir = self.builder.get_object("adjustment_rotation_dipdir")
self.adjustment_rotation_dip = self.builder.get_object("adjustment_rotation_dip")
self.adjustment_rotation_angle = self.builder.get_object("adjustment_rotation_angle")
self.spinbutton_rotation_dipdir = self.builder.get_object("spinbutton_rotation_dipdir")
self.spinbutton_rotation_dip = self.builder.get_object("spinbutton_rotation_dip")
self.spinbutton_rotation_angle = self.builder.get_object("spinbutton_rotation_angle")
self.scrolledwindow_rotate = self.builder.get_object("scrolledwindow_rotate")
self.fig = Figure(dpi=self.settings.get_pixel_density())
self.canvas = FigureCanvas(self.fig)
self.scrolledwindow_rotate.add_with_viewport(self.canvas)
gridspec = GridSpec(1, 2)
original_sp = gridspec.new_subplotspec((0, 0),
rowspan=1, colspan=1)
rotated_sp = gridspec.new_subplotspec((0, 1),
rowspan=1, colspan=1)
self.original_ax = self.fig.add_subplot(original_sp,
projection=self.settings.get_projection())
self.rotated_ax = self.fig.add_subplot(rotated_sp,
projection=self.settings.get_projection())
self.canvas.draw()
self.redraw_plot()
self.dialog.show_all()
self.builder.connect_signals(self)
if sys.platform == "win32":
translate_gui(self.builder)
示例11: gridplot
def gridplot (grid, loc, rowspan=1, colspan=1):
'''
Returns a matplotlib.gridspec.SubplotSpec for a subplot.
The resulting object can then be added to a matplotlib.figure
using the add_subplot() method.
'''
gridspec = GridSpec (grid[0], grid[1])
subplotspec = gridspec.new_subplotspec(loc, rowspan, colspan)
return subplotspec
示例12: plot_flux_decomposition
def plot_flux_decomposition(ss, tm, name=None, source_code=None):
f = plt.figure(figsize=(18, 6))
gs = GridSpec(2, 3, wspace=0.5, hspace=0.5)
ax1 = plt.subplot(gs[0, 0])
ax2 = plt.subplot(gs[0, 1])
ax3 = plt.subplot(gs[0, 2])
ax4 = plt.subplot(gs[1, 0])
ax5 = plt.subplot(gs[1, 1])
ax6 = plt.subplot(gs[1, 2])
first_surface = int(len(ss) / 2)
ax1.scatter(range(first_surface), ss[0:first_surface], s=80, c="r")
ax1.set_title("First part of steady state eigenvector")
ax1.set_ylabel("Population")
ax2.scatter(range(first_surface), [tm[i][i + first_surface] for i in range(first_surface)], s=80, c="r")
ax2.set_title("Transition probabilities (unbound to bound)")
ax2.set_ylabel("Probability")
ax3.scatter(range(first_surface), [ss[i] * tm[i][i + first_surface] for i in range(first_surface)], s=80, c="r")
ax3.set_title("Steady state eigenvector * transition probabilities (unbound to bound)")
ax3.set_ylabel("Population * Probability")
ax4.scatter(range(first_surface, 2 * first_surface), ss[first_surface : 2 * first_surface], s=80, c="b")
ax4.set_title("Second part of steady state eigenvector")
ax4.set_ylabel("Population")
ax5.scatter(range(first_surface), [tm[i + first_surface][i] for i in range(first_surface)], s=80, c="b")
ax5.set_title("Transition probabilities (bound to unbound)")
ax5.set_ylabel("Probability")
ax6.scatter(
range(first_surface, 2 * first_surface),
[ss[i] * tm[i + first_surface][i] for i in range(first_surface)],
s=80,
c="b",
)
ax6.set_title("Steady state eigenvector * transition probabilities (bound to unbound)")
ax6.set_ylabel("Population * Probability")
st = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sts = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
if name:
if source_code is not None:
text = st + " " + name + " in " + source_code
else:
text = st + " " + name
f.text(0.0, 0.0, text, fontsize=12, color="black", ha="left", va="bottom", alpha=0.5)
else:
f.text(0.0, 0.0, st, fontsize=12, color="black", ha="left", va="bottom", alpha=0.5)
gs.tight_layout(f, rect=[0, 0, 1, 1])
plt.savefig("Figures/flux-decomposition-{}-{}".format(sts, name), dpi=150)
# plt.show()
plt.close()
示例13: make_figure
def make_figure(self, type):
self.fig.clf()
if type == 'gd':
pass
elif type == 'mc':
gs = GridSpec(1, 1)
gs.update(hspace=0.7, wspace=0.8)
self.splts = [self.fig.add_subplot(gs[int(i/3), int(i%3)]) for i in range(1*1)] # grid nxn
else:
pass
示例14: plot_steady_state
def plot_steady_state(unbound, bound, pdf_unbound, pdf_bound, ss, name=None, source_code=None):
f = plt.figure(figsize=(12, 12))
gs = GridSpec(2, 2, wspace=0.5, hspace=0.5)
ax1 = plt.subplot(gs[0, 0])
ax2 = plt.subplot(gs[0, 1])
ax3 = plt.subplot(gs[1, 0])
ax4 = plt.subplot(gs[1, 1])
ax1.scatter(range(len(unbound)), unbound, s=80, c="r")
ax1.plot(range(len(unbound)), unbound, lw=2, c="r")
ax2.scatter(range(len(bound)), bound, s=80, c="b")
ax2.plot(range(len(bound)), bound, lw=2, c="b")
ax1.set_title("Unbound energy surface")
ax2.set_title("Bound energy surface")
bins = int(len(ss) / 2)
ax3.plot(range(len(unbound)), ss[0:bins], lw=2, c="r")
ax3.scatter(range(len(unbound)), ss[0:bins], s=80, c="r")
ax3.plot(range(len(pdf_unbound)), pdf_unbound, lw=4, ls="--", c="k")
ax3.set_title("Boltzmann and forward s.s.")
ax4.plot(range(len(bound)), ss[bins : 2 * bins], lw=2, c="b")
ax4.scatter(range(len(bound)), ss[bins : 2 * bins], s=80, c="b")
ax4.plot(range(len(pdf_bound)), pdf_bound, lw=4, ls="--", c="k")
ax4.set_title("Boltzmann and forward s.s.")
ax4.set_xlabel("Reaction coordinate ($\phi$)")
ax3.set_xlabel("Reaction coordinate ($\phi$)")
ax1.set_ylabel("Energy (a.u.)")
ax2.set_ylabel("Energy (a.u.)")
ax3.set_ylabel("Population")
ax4.set_ylabel("Population")
ax1.set_ylim([-15, 20])
ax2.set_ylim([-15, 20])
ax3.set_ylim([0, 0.6])
ax4.set_ylim([0, 0.6])
st = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sts = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
if name:
if source_code is not None:
text = st + " " + name + " in " + source_code
else:
text = st + " " + name
f.text(0.0, 0.0, text, fontsize=12, color="black", ha="left", va="bottom", alpha=0.5)
else:
f.text(0.0, 0.0, st, fontsize=12, color="black", ha="left", va="bottom", alpha=0.5)
gs.tight_layout(f, rect=[0, 0, 1, 1])
# plt.show()
plt.savefig("Figures/steady-state-{}-{}".format(sts, name), dpi=150)
plt.close()
示例15: plot_standard
def plot_standard(corr="acorr"):
os.chdir(tables_dir)
ref = np.loadtxt("stars_lick_val_{0}.txt".format(corr)).T
obs = np.loadtxt("stars_lick_obs_{0}.txt".format(corr)).T
bands = np.loadtxt("bands_matching_standards.txt", usecols=(0), dtype=str).tolist()
bands2, units, error = np.loadtxt("bands.txt", usecols=(0,9,10), dtype=str).T
idx = [list(bands2).index(x) for x in bands]
idx2 = np.array([list(bands).index(x) for x in bands2])
error = error[idx]
units = units[idx]
units = [x.replace("Ang", "\AA") for x in units]
fig = plt.figure(1, figsize=(20,12))
gs = GridSpec(5,5)
gs.update(left=0.03, right=0.988, top=0.98, bottom=0.06, wspace=0.2,
hspace=0.4)
offsets, errs = [], []
for i in range(25):
ax = plt.subplot(gs[i])
plt.locator_params(axis="y", nbins=6)
plt.locator_params(axis="x", nbins=6)
ax.minorticks_on()
# ax.plot(obs[i], ref[i] - obs[i], "ok")
ax.axhline(y=0, ls="--", c="k")
diff = ref[i] - obs[i]
diff, c1, c2 = sigmaclip(diff[np.isfinite(diff)], 2.5, 2.5)
ax.hist(diff, bins=8, color="0.7", histtype='stepfilled')
ylim = plt.ylim()
xlim = plt.xlim()
xlim = np.max(np.abs(xlim))
ax.set_ylim(0, ylim[1] + 2)
ax.set_xlim(-xlim, xlim)
mean = np.nanmean(diff)
N = len(diff)
err = np.nanstd(diff) / np.sqrt(N)
lab = "${0:.2f}\pm{1:.2f}$".format(mean, err)
ax.axvline(x=mean, ls="-", c="r", label=lab)
ax.axvline(x=0, ls="--", c="k")
# ax.axhline(y=float(error[i]))
# ax.axhline(y=-float(error[i]))
# ax.set_xlabel("{0} ({1})".format(bands[i].replace("_", " "), units[i]))
ax.legend(loc=1,prop={'size':12})
ax.set_xlabel("$\Delta$ {0} ({1})".format(bands[i].replace("_", " "),
units[i]))
ax.set_ylabel("Frequency")
offsets.append(mean)
errs.append(err)
offsets = np.array(offsets)[idx2]
errs = np.array(errs)[idx2]
output = os.path.join(home, "plots/lick_stars_{0}.png".format(corr))
plt.savefig(output)
with open(os.path.join(tables_dir, "lick_offsets.txt"), "w") as f:
f.write("# Index Additive Correction\n")
np.savetxt(f, np.column_stack((np.array(bands)[idx2],offsets, errs)),
fmt="%s")