summaryrefslogtreecommitdiff
path: root/src/Witness_complex/example/protected_sets/output_tikz.h
diff options
context:
space:
mode:
authorskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-12-07 09:39:53 +0000
committerskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-12-07 09:39:53 +0000
commit33c51358238382335caf892bbc24759c8aac59a0 (patch)
tree499e768570391c30af22eac4443667604fa717d6 /src/Witness_complex/example/protected_sets/output_tikz.h
parentda39f7cd8a0db5d7fa13c9c87f8fc3e038c10d01 (diff)
parentc8c2f91db880218bb7ab275fbadda53a23f88d35 (diff)
Changes piled up for months
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@932 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0447901e608890eb607456fd12f3ea53547b8f10
Diffstat (limited to 'src/Witness_complex/example/protected_sets/output_tikz.h')
-rw-r--r--src/Witness_complex/example/protected_sets/output_tikz.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/Witness_complex/example/protected_sets/output_tikz.h b/src/Witness_complex/example/protected_sets/output_tikz.h
new file mode 100644
index 00000000..edfd9a5f
--- /dev/null
+++ b/src/Witness_complex/example/protected_sets/output_tikz.h
@@ -0,0 +1,67 @@
+#ifndef OUTPUT_TIKZ_H
+#define OUTPUT_TIKZ_H
+
+#include <vector>
+#include <string>
+#include <algorithm>
+#include <fstream>
+#include <cmath>
+
+void write_tikz_plot(std::vector<FT> data, std::string filename)
+{
+ int n = data.size();
+ FT vmax = *(std::max_element(data.begin(), data.end()));
+ //std::cout << std::log10(vmax) << " " << std::floor(std::log10(vmax));
+
+ FT order10 = pow(10,std::floor(std::log10(vmax)));
+ int digit = std::floor( vmax / order10) + 1;
+ if (digit == 4 || digit == 6) digit = 5;
+ if (digit > 6) digit = 10;
+ FT plot_max = digit*order10;
+ std::cout << plot_max << " " << vmax;
+ FT hstep = 10.0/(n-1);
+ FT wstep = 10.0 / plot_max;
+
+ std::cout << "(eps_max-eps_min)/(N-48) = " << (vmax-*data.begin())/(data.size()-48) << "\n";
+ std::ofstream ofs(filename, std::ofstream::out);
+
+ ofs <<
+ "\\documentclass{standalone}\n" <<
+ "\\usepackage[utf8]{inputenc}\n" <<
+ "\\usepackage{amsmath}\n" <<
+ "\\usepackage{tikz}\n\n" <<
+ "\\begin{document}\n" <<
+ "\\begin{tikzpicture}\n";
+
+ ofs << "\\draw[->] (0,0) -- (0,11);" << std::endl <<
+ "\\draw[->] (0,0) -- (11,0);" << std::endl <<
+ "\\foreach \\i in {1,...,10}" << std::endl <<
+ "\\draw (0,\\i) -- (-0.05,\\i);" << std::endl <<
+ "\\foreach \\i in {1,...,10}" << std::endl <<
+ "\\draw (\\i,0) -- (\\i,-0.05);" << std::endl << std::endl <<
+
+ "\\foreach \\i in {1,...,10}" << std::endl <<
+ "\\draw[dashed] (-0.05,\\i) -- (11,\\i);" << std::endl << std::endl <<
+
+ "\\node at (-0.5,11) {$*$}; " << std::endl <<
+ "\\node at (11,-0.5) {$*$}; " << std::endl <<
+ "\\node at (-0.5,-0.5) {0}; " << std::endl <<
+ "\\node at (-0.5,10) {" << plot_max << "}; " << std::endl <<
+ "%\\node at (10,-0.5) {2}; " << std::endl;
+
+ ofs << "\\draw[red] (0," << wstep*data[0] << ")";
+ for (int i = 1; i < n; ++i)
+ ofs << " -- (" << hstep*i << "," << wstep*data[i] << ")";
+ ofs << ";\n";
+
+ ofs <<
+ "\\end{tikzpicture}\n" <<
+ "\\end{document}";
+
+ ofs.close();
+
+
+
+}
+
+#endif