| 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> | |
| 15 | 14 |
| 16 namespace webrtc { | 15 namespace webrtc { |
| 17 namespace plotting { | 16 namespace plotting { |
| 18 | 17 |
| 19 PythonPlot::PythonPlot() {} | 18 PythonPlot::PythonPlot() {} |
| 20 | 19 |
| 21 PythonPlot::~PythonPlot() {} | 20 PythonPlot::~PythonPlot() {} |
| 22 | 21 |
| 23 void PythonPlot::draw() { | 22 void PythonPlot::draw() { |
| 24 // Write python commands to stdout. Intended program usage is | 23 // Write python commands to stdout. Intended program usage is |
| (...skipping 27 matching lines...) Expand all Loading... |
| 52 // There is a plt.bar function that draws bar plots, | 51 // There is a plt.bar function that draws bar plots, |
| 53 // but it is *way* too slow to be useful. | 52 // but it is *way* too slow to be useful. |
| 54 printf( | 53 printf( |
| 55 "plt.vlines(x%zu, map(lambda t: min(t,0), y%zu), map(lambda t: " | 54 "plt.vlines(x%zu, map(lambda t: min(t,0), y%zu), map(lambda t: " |
| 56 "max(t,0), y%zu), color=rgb_colors[%zu], " | 55 "max(t,0), y%zu), color=rgb_colors[%zu], " |
| 57 "label=\'%s\')\n", | 56 "label=\'%s\')\n", |
| 58 i, i, i, i, series[i].label.c_str()); | 57 i, i, i, i, series[i].label.c_str()); |
| 59 } else if (series[i].style == LINE_GRAPH) { | 58 } else if (series[i].style == LINE_GRAPH) { |
| 60 printf("plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\')\n", i, | 59 printf("plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\')\n", i, |
| 61 i, i, series[i].label.c_str()); | 60 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()); | |
| 67 } else { | 61 } else { |
| 68 printf("raise Exception(\"Unknown graph type\")\n"); | 62 printf("raise Exception(\"Unknown graph type\")\n"); |
| 69 } | 63 } |
| 70 } | 64 } |
| 71 } | 65 } |
| 72 | 66 |
| 73 printf("plt.xlim(%f, %f)\n", xaxis_min, xaxis_max); | 67 printf("plt.xlim(%f, %f)\n", xaxis_min, xaxis_max); |
| 74 printf("plt.ylim(%f, %f)\n", yaxis_min, yaxis_max); | 68 printf("plt.ylim(%f, %f)\n", yaxis_min, yaxis_max); |
| 75 printf("plt.xlabel(\'%s\')\n", xaxis_label.c_str()); | 69 printf("plt.xlabel(\'%s\')\n", xaxis_label.c_str()); |
| 76 printf("plt.ylabel(\'%s\')\n", yaxis_label.c_str()); | 70 printf("plt.ylabel(\'%s\')\n", yaxis_label.c_str()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 95 } | 89 } |
| 96 | 90 |
| 97 Plot* PythonPlotCollection::append_new_plot() { | 91 Plot* PythonPlotCollection::append_new_plot() { |
| 98 Plot* plot = new PythonPlot(); | 92 Plot* plot = new PythonPlot(); |
| 99 plots.push_back(std::unique_ptr<Plot>(plot)); | 93 plots.push_back(std::unique_ptr<Plot>(plot)); |
| 100 return plot; | 94 return plot; |
| 101 } | 95 } |
| 102 | 96 |
| 103 } // namespace plotting | 97 } // namespace plotting |
| 104 } // namespace webrtc | 98 } // namespace webrtc |
| OLD | NEW |