Skip to content

Commit

Permalink
Make plotly figure static
Browse files Browse the repository at this point in the history
  • Loading branch information
ndaelman committed Nov 22, 2024
1 parent 5dfff90 commit ffb375a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/nomad_parser_plugin_boss/schema_packages/schema_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
m_package = SchemaPackage()





class PotentialEnergySurfaceFit(PlotSection, Schema):
# m_def = Section()

Expand Down Expand Up @@ -63,18 +66,21 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
try:
if self.energy_values.shape != (len(self.parameter_1_values), len(self.parameter_2_values)):
raise ValueError('Energy values shape does not match parameter values') # ?

figure = go.Figure(
data=go.Contour(
x=self.parameter_1_values,
y=self.parameter_2_values,
z=self.energy_values.magnitude,
colorbar=dict(title='Energy'),
)
).to_plotly_json()
figure['config'] = {'staticPlot': True}

self.figures.append(
PlotlyFigure(
label='Potential Energy Surface',
figure=go.Figure(
data=go.Contour(
x=self.parameter_1_values,
y=self.parameter_2_values,
z=self.energy_values.magnitude,
colorbar=dict(title='Energy'),
)
).to_plotly_json(),
figure=figure,
),
),
except Exception as e:
Expand Down

0 comments on commit ffb375a

Please sign in to comment.