Commit ac9a9d80 authored by Lee McCuller's avatar Lee McCuller

plots now uses MPL axes object

parent 7194debd
......@@ -150,10 +150,18 @@ You may interact with plot using "plt." methods, e.g.:
ipshell.run_code("plt.title('{}')".format(title))
ipshell()
elif args.plot:
plot_noise(noises)
plt.title(title)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
plot_noise(
noises,
ax = ax,
)
ax.set_title(title)
fig.tight_layout()
if args.save:
plt.savefig(args.save)
fig.savefig(
args.save,
)
else:
plt.show()
......
......@@ -60,9 +60,17 @@ STYLE_MAP = {
}
def plot_noise(noises,):
def plot_noise(
noises,
ax = None,
):
f = noises['Freq']
if ax is None:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
def plot_dict(noises):
#use sorted to force a consistent ordering
#The key lambda in sorted gets the (name, noise) pair and so nn[0] returns the name
......@@ -85,12 +93,12 @@ def plot_noise(noises,):
stylekw.update(style)
except KeyError:
pass
plt.loglog(f, sqrt(noise), **stylekw)
ax.loglog(f, sqrt(noise), **stylekw)
plot_dict(noises)
plt.loglog(f, sqrt(noises['Total']), color='black', label='Total', lw=4)
ax.loglog(f, sqrt(noises['Total']), color='black', label='Total', lw=4)
plt.grid(
ax.grid(
True,
which='both',
lw = .5,
......@@ -98,12 +106,12 @@ def plot_noise(noises,):
alpha = .5,
)
plt.legend(
ax.legend(
ncol=2,
fontsize = 'small',
)
plt.xlabel('Frequency [Hz]')
plt.ylabel(u"Strain [1/\u221AHz]")
plt.xlim([min(f), max(f)])
plt.ylim([3e-25, 1e-21])
ax.set_xlabel('Frequency [Hz]')
ax.set_ylabel(u"Strain [1/\u221AHz]")
ax.set_xlim([min(f), max(f)])
ax.set_ylim([3e-25, 1e-21])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment