Skip to content

Commit

Permalink
Make it possible to edit the plot title
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj authored and andreas-el committed Jan 3, 2024
1 parent 37b376f commit a679981
Showing 1 changed file with 47 additions and 53 deletions.
100 changes: 47 additions & 53 deletions src/ert/gui/tools/plot/plot_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,59 +115,53 @@ def currentPlotChanged(self):
return
key = key_def["key"]

for plot_widget in self._plot_widgets:
index = self._central_tab.indexOf(plot_widget)
if (
index == self._central_tab.currentIndex()
and plot_widget._plotter.dimensionality == key_def["dimensionality"]
):
self._updateCustomizer(plot_widget)
cases = self._case_selection_widget.getPlotCaseNames()
case_to_data_map = {}
for case in cases:
try:
case_to_data_map[case] = self._api.data_for_key(case, key)
except (RequestError, TimeoutError) as e:
logger.exception(e)
msg = f"{e}"

QMessageBox.critical(self, "Request Failed", msg)

observations = None
if key_def["observations"] and cases:
try:
observations = self._api.observations_for_key(cases[0], key)
except (RequestError, TimeoutError) as e:
logger.exception(e)
msg = f"{e}"

QMessageBox.critical(self, "Request Failed", msg)

plot_config = PlotConfig.createCopy(
self._plot_customizer.getPlotConfig()
)
plot_config.setTitle(key)
plot_context = PlotContext(plot_config, cases, key)

case = plot_context.cases()[0] if plot_context.cases() else None

# Check if key is a history key.
# If it is it already has the data it needs
if str(key).endswith("H") or "H:" in str(key):
plot_context.history_data = DataFrame()
else:
try:
plot_context.history_data = self._api.history_data(key, case)
except (RequestError, TimeoutError) as e:
logger.exception(e)
msg = f"{e}"

QMessageBox.critical(self, "Request Failed", msg)
plot_context.history_data = None

plot_context.log_scale = key_def["log_scale"]

plot_widget.updatePlot(plot_context, case_to_data_map, observations)
plot_widget = self._central_tab.currentWidget()

if plot_widget._plotter.dimensionality == key_def["dimensionality"]:
self._updateCustomizer(plot_widget)
cases = self._case_selection_widget.getPlotCaseNames()
case_to_data_map = {}
for case in cases:
try:
case_to_data_map[case] = self._api.data_for_key(case, key)
except (RequestError, TimeoutError) as e:
logger.exception(e)
msg = f"{e}"

QMessageBox.critical(self, "Request Failed", msg)

observations = None
if key_def["observations"] and cases:
try:
observations = self._api.observations_for_key(cases[0], key)
except (RequestError, TimeoutError) as e:
logger.exception(e)
msg = f"{e}"

QMessageBox.critical(self, "Request Failed", msg)

plot_config = PlotConfig.createCopy(self._plot_customizer.getPlotConfig())
plot_context = PlotContext(plot_config, cases, key)

case = plot_context.cases()[0] if plot_context.cases() else None

# Check if key is a history key.
# If it is it already has the data it needs
if str(key).endswith("H") or "H:" in str(key):
plot_context.history_data = DataFrame()
else:
try:
plot_context.history_data = self._api.history_data(key, case)
except (RequestError, TimeoutError) as e:
logger.exception(e)
msg = f"{e}"

QMessageBox.critical(self, "Request Failed", msg)
plot_context.history_data = None

plot_context.log_scale = key_def["log_scale"]

plot_widget.updatePlot(plot_context, case_to_data_map, observations)

def _updateCustomizer(self, plot_widget: PlotWidget):
key_def = self.getSelectedKey()
Expand Down

0 comments on commit a679981

Please sign in to comment.