Add correct formatting of x- and y-labels for EC-plots
This commit is contained in:
parent
514a20604b
commit
5735d011aa
2 changed files with 34 additions and 1 deletions
|
|
@ -49,12 +49,42 @@ def plot_gc(data, options=None):
|
|||
cycle[1].plot(x=options['x_vals'], y=options['y_vals'], ax=ax, c=colours[i][1])
|
||||
|
||||
|
||||
update_labels(options)
|
||||
print(options['xunit'])
|
||||
|
||||
fig, ax = btp.adjust_plot(fig=fig, ax=ax, options=options)
|
||||
|
||||
return data['cycles'], fig, ax
|
||||
|
||||
|
||||
|
||||
def update_labels(options):
|
||||
|
||||
if 'xlabel' not in options.keys():
|
||||
options['xlabel'] = options['x_vals'].capitalize().replace('_', ' ')
|
||||
|
||||
if 'ylabel' not in options.keys():
|
||||
options['ylabel'] = options['y_vals'].capitalize().replace('_', ' ')
|
||||
|
||||
|
||||
if 'xunit' not in options.keys():
|
||||
if options['x_vals'] == 'capacity':
|
||||
options['xunit'] = options['units']['capacity']
|
||||
elif options['x_vals'] == 'specific_capacity':
|
||||
options['xunit'] = f"{options['units']['capacity']} {options['units']['mass']}$^{{-1}}$"
|
||||
elif options['x_vals'] == 'time':
|
||||
options['xunit'] = options['units']['time']
|
||||
elif options['x_vals'] == 'ions':
|
||||
options['xunit'] = None
|
||||
|
||||
|
||||
if 'yunit' not in options.keys():
|
||||
if options['y_vals'] == 'voltage':
|
||||
options['yunit'] = options['units']['voltage']
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def update_cycles_list(cycles, options: dict) -> None:
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,10 @@ def adjust_plot(fig, ax, options):
|
|||
ax.set_ylabel('')
|
||||
|
||||
if not options['hide_x_labels']:
|
||||
ax.set_xlabel(f'{options["xlabel"]}')
|
||||
if not options['xunit']:
|
||||
ax.set_xlabel(f'{options["xlabel"]}')
|
||||
else:
|
||||
ax.set_xlabel(f'{options["xlabel"]} [{options["xunit"]}]')
|
||||
else:
|
||||
ax.set_xlabel('')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue