# -*-Python-*-
# Created by eldond at 2018 Jun 21 14:01
"""
This script makes a dummy figure to use in the example LaTeX document. It is called by build_latex_example.py.
Usage suggestion:
- Make a small wrapper script around your regular plotting routine.
- Use the wrapper to set up a particular display environment or pass in specific keywords to the normal plot script.
- At the end, save the figure like at the end of this script.
"""
# Make a figure
defaultVars(figures_have_keywords='yes_they_do', figure_name='latex_dummy_fig', figsize=[12.5, 5.4], save_to=scratch)
fig, axs = plt.subplots(2, sharex=True, figsize=figsize)
axs[0].set_title(figures_have_keywords)
axs[0].set_ylabel('Y (uF)')
axs[1].set_ylabel('y (nF)')
axs[-1].set_xlabel('X (ferrets)')
x = linspace(0, 10, 21)
y = 1501.3 + 9.351 * x - 7.3 * x ** 2
Y = 2.7 + 1.2 * x + 0.045 * x ** 2
axs[0].plot(x, Y)
axs[1].plot(x, y)
# Figure saving
filename = evalExpr(root['SETTINGS']['SETUP']['workDir']) + os.sep + figure_name + '.pdf'
fig.savefig(filename)
print('Saved figure as {}'.format(filename))
save_to[figure_name + '.pdf'] = OMFITpath(filename)
# Cleanup
plt.close(fig)