Commit 63272c1c authored by Thomas Fetzer's avatar Thomas Fetzer Committed by Timo Koch
Browse files

[io][gnuplotinterface] New signature for plot and add..ToPlot functions

Fix deprecation of plot(), thanks Timo for the heads-up.

(cherry picked from commit 25fd3f26)
parent 4611b301
Differences Between DuMuX 2.11 and DuMuX 2.12
=============================================
* IMPORTANT NOTES:
- DuMuX 2.12 is expected to run based on Dune 2.4.1, 2.5 and the Dune
master. We will try to keep the compatibility with the Dune master
as long as it is technically feasible and our resources allow it. If
you want to use Dumux multidomain models, you have to stick with the
Dune 2.4 core and specific versions of other modules, see
`test/multidomain/README` for details.
- DuMux 2.12 requires at least GCC 4.9 or Clang 3.5 in their C++-14 mode.
- For employing corner-point grids by means of opm-grid (former
dune-cornerpoint), the OPM release 2016.04 has to be used.
* IMPROVEMENTS and ENHANCEMENTS:
* IMMEDIATE INTERFACE CHANGES not allowing/requiring a deprecation period:
- gnuplotinterface.hh: The add...ToPlot() functions have changed signature,
the curve name/title is not mandatory anymore and can be specified together
with the curve options.
* Deprecated PROPERTY and PARAMETER NAMES, to be removed after 2.12: BEWARE: The
compiler will not print any warning if a deprecated property or parameter name
is used. If possible, a run-time warning will appear in the summary lines
after the corresponding run.
* Deprecated CLASSES/FILES, to be removed after 2.12:
* Deprecated MEMBER FUNCTIONS, to be removed after 2.12:
* DELETED classes/files, property names, constants/enums,
member functions, which have been deprecated in DuMuX 2.11 :
- Everything listed as deprecated below has been removed.
Differences Between DuMuX 2.10 and DuMuX 2.11
=============================================
......
......@@ -87,11 +87,11 @@ public:
* \param plottingWindowNumber Change the number of the window in which the plot is shown
* \param terminalType Set the terminal type for the graphical output
*/
DUNE_DEPRECATED_MSG("The signature of plot(string, int, string) has been changed to plot(string, string, int).")
DUNE_DEPRECATED_MSG("The signature of plot(string, int, string) has been changed to plot(string).")
void plot(const std::string &title, const unsigned int plottingWindowNumber, const std::string& terminalType = "x11")
{
setTerminalType(terminalType);
plot(title, terminalType, plottingWindowNumber);
plot(title);
}
/*!
......@@ -125,8 +125,7 @@ public:
for (unsigned int i = 0; i < curveFile_.size(); ++i)
{
plot += + " " + curveFile_[i]
+ " " + curveOptions_[i]
+ " title '" + curveTitle_[i] + "'";
+ " " + curveOptions_[i];
if (i < curveFile_.size()-1)
plot += ",\\";
plot += "\n";
......@@ -168,9 +167,8 @@ public:
*/
void resetPlot()
{
curveFile_.resize(0);
curveOptions_.resize(0);
curveTitle_.resize(0);
curveFile_.clear();
curveOptions_.clear();
plotOptions_ = "";
}
......@@ -194,55 +192,66 @@ public:
assert("Could not close pipe to Gnuplot!");
}
DUNE_DEPRECATED_MSG("The signature of addFunctionToPlot(string, string, string) has been changed to addFunctionToPlot(string, string).")
void addFunctionToPlot(const std::string function,
const std::string plotName,
const std::string plotOptions)
{
addFunctionToPlot(function, "title '" + plotName + "' " + plotOptions);
}
/*!
* \brief Adds a function to list of plotted lines
* \brief Adds a function to list of plots
*
* \param function Function to be plotted
* \param plotName The name of the data set
* \param plotOptions Specific gnuplot options passed to this plot
* \param options Specific gnuplot options passed to this plot
*/
void addFunctionToPlot(const std::string function,
const std::string plotName,
const std::string plotOptions = "with lines")
const std::string options = "with lines")
{
curveFile_.push_back(function);
curveOptions_.push_back(plotOptions);
curveTitle_.push_back(plotName);
curveOptions_.push_back(options);
}
DUNE_DEPRECATED_MSG("The signature of addFileToPlot(string, string, string) has been changed to addFileToPlot(string, string).")
void addFileToPlot(const std::string file,
const std::string plotName,
const std::string plotOptions)
{
addFileToPlot(file, "title '" + plotName + "' " + plotOptions);
}
/*!
* \brief Adds a file to list of plotted lines
* \brief Adds a file to list of plots
*
* \param file Function to be plotted
* \param plotName The name of the data set
* \param plotOptions Specific gnuplot options passed to this plot
* \param fileName Name and path of the file to be plotted
* \param options Specific gnuplot options passed to this plot
*/
void addFileToPlot(const std::string file,
const std::string plotName,
const std::string plotOptions = "with lines")
void addFileToPlot(const std::string fileName,
const std::string options = "with lines")
{
curveFile_.push_back("'" + file + "'");
curveOptions_.push_back(plotOptions);
curveTitle_.push_back(plotName);
curveFile_.push_back("'" + fileName + "'");
curveOptions_.push_back(options);
}
/*!
* \brief Adds a data set and writes a data file
*
* The title of the plot can be changed by setting the title in the options
*
* \param x Vector containing the x-axis data points
* \param y Vector containing the y-axis data points
* \param plotName The name of the data set
* \param plotOptions Specific gnuplot options passed to this plot
* \param fileName The name of the written data file
* \param options Specific gnuplot options passed to this plot
*/
void addDataSetToPlot(const std::vector<Scalar>& x,
const std::vector<Scalar>& y,
const std::string plotName,
const std::string plotOptions = "with lines")
const std::string fileName,
const std::string options = "with lines")
{
assert(x.size() == y.size());
//write data to file
std::string fileName = plotName + ".dat";
// write data to file
std::ofstream file;
file.open(fileName);
for (unsigned int i = 0; i < x.size(); i++)
......@@ -255,8 +264,7 @@ public:
// adding file to list of plotted lines
curveFile_.push_back("'" + fileName + "'");
curveOptions_.push_back(plotOptions);
curveTitle_.push_back(plotName);
curveOptions_.push_back(options);
}
/*!
......@@ -382,7 +390,6 @@ private:
std::string linetype_;
StringVector curveFile_;
StringVector curveOptions_;
StringVector curveTitle_;
bool interaction_;
Scalar xRangeMin_;
Scalar xRangeMax_;
......
......@@ -59,9 +59,9 @@ int main()
gnuplot.setDatafileSeparator(',');
gnuplot.setOption("set arrow from 0,0 to 2,20 head filled lc rgb 'dark-gray'");
gnuplot.setOption("set label 'arrow' at 1,15 center tc rgb 'dark-gray'");
gnuplot.addDataSetToPlot(x, y, "dataSet_f(x)=x^2", "every 5 w lp ps 2");
gnuplot.addFunctionToPlot("x**3", "function_f(x)=x^3");
gnuplot.addFileToPlot("dataSet_f(x)=x^2.dat", "file_f(x)=x^2.dat");
gnuplot.addDataSetToPlot(x, y, "dataSet.csv", "every 5 w lp ps 2");
gnuplot.addFunctionToPlot("x**3", "title 'function_f(x)=x^3'");
gnuplot.addFileToPlot("dataSet.csv");
gnuplot.plot("plot");
exit(0);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment