OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/tools/event_log_visualizer/plot_python.h" | 11 #include "webrtc/tools/event_log_visualizer/plot_python.h" |
12 | 12 |
13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 #include <memory> |
14 | 15 |
15 namespace webrtc { | 16 namespace webrtc { |
16 namespace plotting { | 17 namespace plotting { |
17 | 18 |
18 PythonPlot::PythonPlot() {} | 19 PythonPlot::PythonPlot() {} |
19 | 20 |
20 PythonPlot::~PythonPlot() {} | 21 PythonPlot::~PythonPlot() {} |
21 | 22 |
22 void PythonPlot::draw() { | 23 void PythonPlot::draw() { |
23 // Write python commands to stdout. Intended program usage is | 24 // Write python commands to stdout. Intended program usage is |
(...skipping 27 matching lines...) Expand all Loading... |
51 // There is a plt.bar function that draws bar plots, | 52 // There is a plt.bar function that draws bar plots, |
52 // but it is *way* too slow to be useful. | 53 // but it is *way* too slow to be useful. |
53 printf( | 54 printf( |
54 "plt.vlines(x%zu, map(lambda t: min(t,0), y%zu), map(lambda t: " | 55 "plt.vlines(x%zu, map(lambda t: min(t,0), y%zu), map(lambda t: " |
55 "max(t,0), y%zu), color=rgb_colors[%zu], " | 56 "max(t,0), y%zu), color=rgb_colors[%zu], " |
56 "label=\'%s\')\n", | 57 "label=\'%s\')\n", |
57 i, i, i, i, series[i].label.c_str()); | 58 i, i, i, i, series[i].label.c_str()); |
58 } else if (series[i].style == LINE_GRAPH) { | 59 } else if (series[i].style == LINE_GRAPH) { |
59 printf("plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\')\n", i, | 60 printf("plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\')\n", i, |
60 i, i, series[i].label.c_str()); | 61 i, i, series[i].label.c_str()); |
| 62 } else if (series[i].style == LINE_DOT_GRAPH) { |
| 63 printf( |
| 64 "plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\', " |
| 65 "marker='.')\n", |
| 66 i, i, i, series[i].label.c_str()); |
61 } else { | 67 } else { |
62 printf("raise Exception(\"Unknown graph type\")\n"); | 68 printf("raise Exception(\"Unknown graph type\")\n"); |
63 } | 69 } |
64 } | 70 } |
65 } | 71 } |
66 | 72 |
67 printf("plt.xlim(%f, %f)\n", xaxis_min, xaxis_max); | 73 printf("plt.xlim(%f, %f)\n", xaxis_min, xaxis_max); |
68 printf("plt.ylim(%f, %f)\n", yaxis_min, yaxis_max); | 74 printf("plt.ylim(%f, %f)\n", yaxis_min, yaxis_max); |
69 printf("plt.xlabel(\'%s\')\n", xaxis_label.c_str()); | 75 printf("plt.xlabel(\'%s\')\n", xaxis_label.c_str()); |
70 printf("plt.ylabel(\'%s\')\n", yaxis_label.c_str()); | 76 printf("plt.ylabel(\'%s\')\n", yaxis_label.c_str()); |
(...skipping 18 matching lines...) Expand all Loading... |
89 } | 95 } |
90 | 96 |
91 Plot* PythonPlotCollection::append_new_plot() { | 97 Plot* PythonPlotCollection::append_new_plot() { |
92 Plot* plot = new PythonPlot(); | 98 Plot* plot = new PythonPlot(); |
93 plots.push_back(std::unique_ptr<Plot>(plot)); | 99 plots.push_back(std::unique_ptr<Plot>(plot)); |
94 return plot; | 100 return plot; |
95 } | 101 } |
96 | 102 |
97 } // namespace plotting | 103 } // namespace plotting |
98 } // namespace webrtc | 104 } // namespace webrtc |
OLD | NEW |