Skip to content

Commit

Permalink
Rounding option
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomarchioro committed Jan 7, 2022
1 parent 11d05bf commit ccac18f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion energydiagram/energydiagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, aspect='equal'):
self.offset_ratio = 0.02
self.color_bottom_text = 'blue'
self.aspect = aspect
self.round_energies_at_digit = "keep all digits"
# data
self.pos_number = 0
self.energies = []
Expand Down Expand Up @@ -98,7 +99,10 @@ def add_level(self, energy, bottom_text='', position=None, color='k',
raise ValueError(
"Position must be None or 'last' (abrv. 'l') or in case an integer or float specifing the position. It was: %s" % position)
if top_text == 'Energy':
top_text = energy
if self.round_energies_at_digit == "keep all digits":
top_text = energy
else:
top_text = round(energy,self.round_energies_at_digit)

link = []
self.colors.append(color)
Expand Down

0 comments on commit ccac18f

Please sign in to comment.