private void savePlotAsImage() {
    // get the possible image name.
    String imageName = "ScreePlot.png";

    // Ask the user to specify a file name for saving the histo.
    String pathSep = File.separator;
    JFileChooser fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    // fc.setCurrentDirectory(new File(workingDirectory + pathSep + imageName + ".png"));
    fc.setAcceptAllFileFilterUsed(false);

    // File f = new File(workingDirectory + pathSep + imageName + ".png");
    // fc.setSelectedFile(f);

    // set the filter.
    ArrayList<ExtensionFileFilter> filters = new ArrayList<ExtensionFileFilter>();
    String[] extensions = ImageIO.getReaderFormatNames(); // {"PNG", "JPEG", "JPG"};
    String filterDescription = "Image Files (" + extensions[0];
    for (int i = 1; i < extensions.length; i++) {
      filterDescription += ", " + extensions[i];
    }
    filterDescription += ")";
    ExtensionFileFilter eff = new ExtensionFileFilter(filterDescription, extensions);
    fc.setFileFilter(eff);

    int result = fc.showSaveDialog(this);
    File file = null;
    if (result == JFileChooser.APPROVE_OPTION) {
      file = fc.getSelectedFile();
      // see if file has an extension.
      if (file.toString().lastIndexOf(".") <= 0) {
        String fileName = file.toString() + ".png";
        file = new File(fileName);
      }

      String fileDirectory = file.getParentFile() + pathSep;
      //            if (!fileDirectory.equals(workingDirectory)) {
      //                workingDirectory = fileDirectory;
      //            }

      // see if the file exists already, and if so, should it be overwritten?
      if (file.exists()) {
        Object[] options = {"Yes", "No"};
        int n =
            JOptionPane.showOptionDialog(
                this,
                "The file already exists.\n" + "Would you like to overwrite it?",
                "Whitebox GAT Message",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null, // do not use a custom Icon
                options, // the titles of buttons
                options[0]); // default button title

        if (n == JOptionPane.YES_OPTION) {
          file.delete();
        } else if (n == JOptionPane.NO_OPTION) {
          return;
        }
      }
      if (!saveToImage(file.toString())) {
        //                showFeedback("An error occurred while saving the map to the image file.");
      }
    }
  }