def currentPlotChanged(self): key_def = self.getSelectedKey() 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 = {case: self._api.data_for_key(case, key)[key] for case in cases} if len(key_def["observations"]) > 0: observations = self._api.observations_for_obs_keys(cases[0], key_def["observations"]) else: observations = None plot_config = PlotConfig.createCopy(self._plot_customizer.getPlotConfig()) plot_config.setTitle(key) plot_context = PlotContext(plot_config, cases, key) if key_def["has_refcase"]: plot_context.refcase_data = self._api.refcase_data(key) plot_widget.updatePlot(plot_context, case_to_data_map, observations)
def createPlotContext(self, figure): key = self.getSelectedKey() cases = self._case_selection_widget.getPlotCaseNames() data_gatherer = self.getDataGathererForKey(key) plot_config = PlotConfig.createCopy(self._plot_customizer.getPlotConfig()) plot_config.setTitle(key) return PlotContext(self._ert, figure, plot_config, cases, key, data_gatherer)
def createPlotContext(self, figure): key = self.getSelectedKey() cases = self.__case_selection_widget.getPlotCaseNames() data_gatherer = next((data_gatherer for data_gatherer in self.__data_gatherers if data_gatherer.canGatherDataForKey(key)), None) plot_config = PlotConfig(key) self.applyCustomization(plot_config) return PlotContext(self.__ert, figure, plot_config, cases, key, data_gatherer)
def __createPlotContext(cls, shell_context, data_gatherer, key): """ :type shell_context: ShellContext :param data_gatherer: PlotDataGatherer :param key: str """ figure = plt.figure() figure.set_tight_layout(True) cases = shell_context["plot_settings"].getCurrentPlotCases() plot_config = PlotConfig(key) plot_config.copyConfigFrom(shell_context["plot_settings"].plotConfig()) if plot_config.isUnnamed(): plot_config.setTitle(key) plot_context = PlotContext(shell_context.ert(), figure, plot_config, cases, key, data_gatherer) return plot_context
def _createPlotContext(cls, shell_context, data_gatherer, key): """ :type shell_context: ShellContext :param data_gatherer: PlotDataGatherer :param key: str """ figure = plt.figure() figure.set_tight_layout(True) cases = shell_context["plot_settings"].getCurrentPlotCases() plot_config = PlotConfig(key) #plot settings should keep of track of single attributes and only apply the changed ones... plot_config.copyConfigFrom(shell_context["plot_settings"].plotConfig()) if plot_config.isUnnamed(): plot_config.setTitle(key) #Apply data type specific changes for statistics... PlotConfigFactory.updatePlotConfigForKey(shell_context.ert(), key, plot_config) plot_context = PlotContext(shell_context.ert(), figure, plot_config, cases, key, data_gatherer) return plot_context