Skip to content

Commit

Permalink
Add possibility to change font size
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomarchioro committed Sep 15, 2022
1 parent f87acbb commit a510ce1
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions energydiagram/energydiagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def __init__(self, aspect='equal'):
self.color_bottom_text = 'blue'
self.aspect = aspect
self.round_energies_at_digit = "keep all digits"
self.top_text_fontsize = "medium"
self.bottom_text_fontsize = "medium"
self.right_text_fontsize = "medium"
self.left_text_fontsize = "medium"
# data
self.pos_number = 0
self.energies = []
Expand Down Expand Up @@ -262,28 +266,32 @@ def plot(self, show_IDs=False, ylabel="Energy / $kcal$ $mol^{-1}$", ax: plt.Axes
level[0]+self.offset, # Y
level[3], # self.top_texts
horizontalalignment='center',
verticalalignment='bottom')
verticalalignment='bottom',
fontsize=self.bottom_text_fontsize)

self.ax.text(start + self.dimension, # X
level[0], # Y
level[5], # self.bottom_text
level[5], # self.right_text
horizontalalignment='left',
verticalalignment='center',
color=self.color_bottom_text)
color=self.color_bottom_text,
fontsize=self.left_text_fontsize)

self.ax.text(start, # X
level[0], # Y
level[6], # self.bottom_text
level[6], # self.left_text
horizontalalignment='right',
verticalalignment='center',
color=self.color_bottom_text)
color=self.color_bottom_text,
fontsize=self.right_text_fontsize)

self.ax.text(start + self.dimension/2., # X
level[0] - self.offset*2, # Y
level[2], # self.bottom_text
horizontalalignment='center',
verticalalignment='top',
color=self.color_bottom_text)
color=self.color_bottom_text,
fontsize=self.top_text_fontsize)
if show_IDs:
# for showing the ID allowing the user to identify the level
for ind, level in enumerate(data):
Expand Down Expand Up @@ -359,6 +367,8 @@ def __auto_adjust(self):

if __name__ == '__main__':
a = ED()
a.bottom_text_fontsize='xx-small'
a.top_text_fontsize='xx-small'
a.add_level(0, 'Separated Reactants')
a.add_level(-5.4, 'mlC1')
a.add_level(-15.6, 'mlC2', 'last',)
Expand Down

0 comments on commit a510ce1

Please sign in to comment.