code: def plot_optimum_prediction_fraction_correct_cutoffs_over_range(self, analysis_set, min_stability_classication_x_cutoff, max_stability_classication_x_cutoff, suppress_plot = False, analysis_file_prefix = None, verbose = True):
          '''Plots the optimum cutoff for the predictions to maximize the fraction correct metric over a range of experimental cutoffs.
             Returns the average scalar corresponding to the best value of fraction correct over a range of cutoff values for the experimental cutoffs.'''
          analysis_set_prefix = ''
          plot_filename = None
          if not suppress_plot:
              output_filename_prefix = '{0}{1}optimum_fraction_correct_at_varying_kcal_mol'.format(analysis_file_prefix, analysis_set_prefix)
              plot_filename = output_filename_prefix + '.png'
              csv_filename = output_filename_prefix + '.txt'
          lines = ['ExperimentalCutoff,BestPredictionCutoff']
          x_cutoff = min_stability_classication_x_cutoff
          x_values = []
          y_values = []
          avg_scale = 0
          plot_graph = self.generate_plots and not(suppress_plot)
          while x_cutoff < max_stability_classication_x_cutoff + 0.1:
              max_value_cutoff, max_value, fraction_correct_range = self.determine_optimum_fraction_correct_cutoffs(analysis_set, self.dataframe, x_cutoff)
              if plot_graph:
                  lines.append(','.join(map(str, (x_cutoff, max_value_cutoff))))
              x_values.append(x_cutoff)
              y_values.append(max_value_cutoff)
              avg_scale += max_value_cutoff / x_cutoff
              x_cutoff += 0.1
          if plot_graph:
              write_file(csv_filename, '\n'.join(lines))
          avg_scale = avg_scale / len(x_values)
          x_values = numpy.array(x_values)
          y_values = numpy.array(y_values)
          scalars = y_values / x_values
          average_scalar = numpy.mean(scalars)
          plot_label_1 = 'Scalar == %0.2f' % average_scalar
          plot_label_2 = 'sigma == %0.2f' % numpy.std(scalars)
          if plot_graph:
              if not(os.path.exists(plot_filename) and not(self.recreate_graphs)):
                  if verbose:
                      self.log('Saving scatterplot to %s.' % plot_filename)
                      self.log('Saving plot of approximate optimal fraction correct cutoffs over varying experimental cutoffs to %s.' % plot_filename)
                  title = 'Optimum cutoff for fraction correct metric at varying experimental cutoffs'
                  if analysis_set:
                      title += ' for {0}'.format(analysis_set)
                  r_script = '''library(ggplot2)
  library(gridExtra)
  library(scales)
  library(qualV)
  png('%(plot_filename)s', height=4096, width=4096, bg="white", res=600)
  plot_data <- read.csv('%(csv_filename)s', header=T)
  max_y = max(plot_data$BestPredictionCutoff)
  p <- ggplot(data = plot_data, aes(x = ExperimentalCutoff, y = BestPredictionCutoff)) +
   xlab("Experimental cutoff (kcal/mol)") +
   ylab("Optimal prediction cutoff (energy units)") +
   ggtitle("%(title)s") +
   geom_point() +
   geom_line() +
   geom_smooth() +
   geom_text(hjust=0, size=4, color="black", aes(0.5, max_y, fontface="plain", family = "sans", label="%(plot_label_1)s"), parse = T) +
   geom_text(hjust=0, size=4, color="black", aes(0.5, max_y - 0.5, fontface="plain", family = "sans", label="%(plot_label_2)s"), parse = T)
  p
  dev.off()'''
                  RInterface._runRScript(r_script % locals())
          return average_scalar, plot_filename