Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: webrtc/tools/event_log_visualizer/plot_python.cc

Issue 2179223003: Convenience functions to set axis properties in visualization tool. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Change literal type to avoid VC++ compile warning Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/tools/event_log_visualizer/plot_python.h ('k') | webrtc/tools/tools.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/tools/event_log_visualizer/plot_python.cc
diff --git a/webrtc/tools/event_log_visualizer/plot_python.cc b/webrtc/tools/event_log_visualizer/plot_python.cc
index 211d33679cb24b737078be8bda47e1c362d069db..d4583444efbb786ab69742ea1543e30ae6d8454c 100644
--- a/webrtc/tools/event_log_visualizer/plot_python.cc
+++ b/webrtc/tools/event_log_visualizer/plot_python.cc
@@ -11,6 +11,7 @@
#include "webrtc/tools/event_log_visualizer/plot_python.h"
#include <stdio.h>
+
#include <memory>
namespace webrtc {
@@ -20,62 +21,62 @@ PythonPlot::PythonPlot() {}
PythonPlot::~PythonPlot() {}
-void PythonPlot::draw() {
+void PythonPlot::Draw() {
// Write python commands to stdout. Intended program usage is
// ./event_log_visualizer event_log160330.dump | python
- if (!series.empty()) {
- printf("color_count = %zu\n", series.size());
+ if (!series_list_.empty()) {
+ printf("color_count = %zu\n", series_list_.size());
printf(
"hls_colors = [(i*1.0/color_count, 0.25+i*0.5/color_count, 0.8) for i "
"in range(color_count)]\n");
printf("rgb_colors = [colorsys.hls_to_rgb(*hls) for hls in hls_colors]\n");
- for (size_t i = 0; i < series.size(); i++) {
+ for (size_t i = 0; i < series_list_.size(); i++) {
// List x coordinates
printf("x%zu = [", i);
- if (series[i].points.size() > 0)
- printf("%G", series[i].points[0].x);
- for (size_t j = 1; j < series[i].points.size(); j++)
- printf(", %G", series[i].points[j].x);
+ if (series_list_[i].points.size() > 0)
+ printf("%G", series_list_[i].points[0].x);
+ for (size_t j = 1; j < series_list_[i].points.size(); j++)
+ printf(", %G", series_list_[i].points[j].x);
printf("]\n");
// List y coordinates
printf("y%zu = [", i);
- if (series[i].points.size() > 0)
- printf("%G", series[i].points[0].y);
- for (size_t j = 1; j < series[i].points.size(); j++)
- printf(", %G", series[i].points[j].y);
+ if (series_list_[i].points.size() > 0)
+ printf("%G", series_list_[i].points[0].y);
+ for (size_t j = 1; j < series_list_[i].points.size(); j++)
+ printf(", %G", series_list_[i].points[j].y);
printf("]\n");
- if (series[i].style == BAR_GRAPH) {
+ if (series_list_[i].style == BAR_GRAPH) {
// There is a plt.bar function that draws bar plots,
// but it is *way* too slow to be useful.
printf(
"plt.vlines(x%zu, map(lambda t: min(t,0), y%zu), map(lambda t: "
"max(t,0), y%zu), color=rgb_colors[%zu], "
"label=\'%s\')\n",
- i, i, i, i, series[i].label.c_str());
- } else if (series[i].style == LINE_GRAPH) {
+ i, i, i, i, series_list_[i].label.c_str());
+ } else if (series_list_[i].style == LINE_GRAPH) {
printf("plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\')\n", i,
- i, i, series[i].label.c_str());
- } else if (series[i].style == LINE_DOT_GRAPH) {
+ i, i, series_list_[i].label.c_str());
+ } else if (series_list_[i].style == LINE_DOT_GRAPH) {
printf(
"plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\', "
"marker='.')\n",
- i, i, i, series[i].label.c_str());
+ i, i, i, series_list_[i].label.c_str());
} else {
printf("raise Exception(\"Unknown graph type\")\n");
}
}
}
- printf("plt.xlim(%f, %f)\n", xaxis_min, xaxis_max);
- printf("plt.ylim(%f, %f)\n", yaxis_min, yaxis_max);
- printf("plt.xlabel(\'%s\')\n", xaxis_label.c_str());
- printf("plt.ylabel(\'%s\')\n", yaxis_label.c_str());
- printf("plt.title(\'%s\')\n", title.c_str());
- if (!series.empty()) {
+ printf("plt.xlim(%f, %f)\n", xaxis_min_, xaxis_max_);
+ printf("plt.ylim(%f, %f)\n", yaxis_min_, yaxis_max_);
+ printf("plt.xlabel(\'%s\')\n", xaxis_label_.c_str());
+ printf("plt.ylabel(\'%s\')\n", yaxis_label_.c_str());
+ printf("plt.title(\'%s\')\n", title_.c_str());
+ if (!series_list_.empty()) {
printf("plt.legend(loc=\'best\', fontsize=\'small\')\n");
}
}
@@ -84,19 +85,19 @@ PythonPlotCollection::PythonPlotCollection() {}
PythonPlotCollection::~PythonPlotCollection() {}
-void PythonPlotCollection::draw() {
+void PythonPlotCollection::Draw() {
printf("import matplotlib.pyplot as plt\n");
printf("import colorsys\n");
- for (size_t i = 0; i < plots.size(); i++) {
+ for (size_t i = 0; i < plots_.size(); i++) {
printf("plt.figure(%zu)\n", i);
- plots[i]->draw();
+ plots_[i]->Draw();
}
printf("plt.show()\n");
}
-Plot* PythonPlotCollection::append_new_plot() {
+Plot* PythonPlotCollection::AppendNewPlot() {
Plot* plot = new PythonPlot();
- plots.push_back(std::unique_ptr<Plot>(plot));
+ plots_.push_back(std::unique_ptr<Plot>(plot));
return plot;
}
« no previous file with comments | « webrtc/tools/event_log_visualizer/plot_python.h ('k') | webrtc/tools/tools.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698