diff --git a/dumux/io/gnuplotinterface.hh b/dumux/io/gnuplotinterface.hh
index b5589f79b8951c40e583cb08d4e705e406d9182f..024c0b46891d9e833cc65581a24494ddce94df42 100644
--- a/dumux/io/gnuplotinterface.hh
+++ b/dumux/io/gnuplotinterface.hh
@@ -64,7 +64,7 @@ public:
     //! \brief The constructor
     GnuplotInterface(bool persist = true) :
         pipe_(0), openPlotWindow_(true), persist_(persist),
-        terminalType_("x11"),
+        terminalType_("x11"), outputDirectory_("./"),
         datafileSeparator_(' '), linetype_("solid"),
         xRangeIsSet_(false), yRangeIsSet_(false),
         xLabel_(""), yLabel_(""),
@@ -144,9 +144,9 @@ public:
             plot += "set term pngcairo size 800,600 " + linetype_ + " \n";
             plot += "set output \"" + filename + ".png\"\n";
             plot += "replot\n";
-            std::string fileName = filename + ".gp";
+            std::string gnuplotFileName = outputDirectory_ + filename + ".gp";
             std::ofstream file;
-            file.open(fileName);
+            file.open(gnuplotFileName);
             file << plot;
             file.close();
         }
@@ -253,7 +253,7 @@ public:
 
         // write data to file
         std::ofstream file;
-        file.open(fileName);
+        file.open(outputDirectory_ + fileName);
         for (unsigned int i = 0; i < x.size(); i++)
         {
             checkNumber(x[i], "x[i] i=" + std::to_string(i) + " in " + fileName);
@@ -353,6 +353,16 @@ public:
         terminalType_ = terminal;
     }
 
+    /*!
+     * \brief Sets the output directory for data and gnuplot files
+     *
+     * \param outputDirectory The user-specified terminal
+     */
+    void setOutputDirectory(std::string outputDirectory)
+    {
+        outputDirectory_ = outputDirectory + "/";
+    }
+
     /*!
      * \brief Use dashed (true) or solid (false) lines
      *
@@ -386,6 +396,7 @@ private:
     bool openPlotWindow_;
     bool persist_;
     std::string terminalType_;
+    std::string outputDirectory_;
     char datafileSeparator_;
     std::string linetype_;
     StringVector curveFile_;
diff --git a/test/io/gnuplotinterface/CMakeLists.txt b/test/io/gnuplotinterface/CMakeLists.txt
index 35b9be2d7f2a130c4155cd495d16a4af2db317f2..65e5411b577cbee0e051ad20ab827987ca8b7a34 100644
--- a/test/io/gnuplotinterface/CMakeLists.txt
+++ b/test/io/gnuplotinterface/CMakeLists.txt
@@ -1,3 +1,4 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output")
 add_dumux_test(test_gnuplotinterface test_gnuplotinterface test_gnuplotinterface.cc
   ${CMAKE_CURRENT_BINARY_DIR}/test_gnuplotinterface)
 
diff --git a/test/io/gnuplotinterface/test_gnuplotinterface.cc b/test/io/gnuplotinterface/test_gnuplotinterface.cc
index 1bdf5fc288a90698cfd8ad464f199f9208c04f82..05c72643ecc17f45b602c2f1f7e5204081fc2ee2 100644
--- a/test/io/gnuplotinterface/test_gnuplotinterface.cc
+++ b/test/io/gnuplotinterface/test_gnuplotinterface.cc
@@ -52,6 +52,7 @@ int main()
         yMax = max(yMax, y[i]);
     }
 
+    gnuplot.setOutputDirectory("output");
     gnuplot.setXRange(0, 5);
     gnuplot.setYRange(yMin, yMax);
     gnuplot.setXlabel("x [-]");