Skip to content

Commit c807fa5

Browse files
committed
- Removed vertical grid lines
- Fixed plotting errors when only one element is present Change-Id: I3cad9e2027e670576b90ce0d465fa92781eeaa7c Signed-off-by: panacotta <[email protected]>
1 parent 2dc2ca2 commit c807fa5

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

papiplot/src/plot.c

+22-13
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ void printhelp(char** argv){
5959
"\tsudo apt-get install gnuplot\n\n");
6060
}
6161

62-
6362
int main(int argc, char **argv) {
6463
int c, len;
6564
res_x = 1680;
@@ -139,9 +138,6 @@ void configure_handle(gnuplot_ctrl * h, int number_of_events, int number_of_ele
139138

140139
gnuplot_cmd(h, "dx=.7");
141140
gnuplot_cmd(h, "n=%d", number_of_events);
142-
gnuplot_cmd(h, "total_box_width_relative=0.3");
143-
gnuplot_cmd(h, "gap_width_relative=0.1");
144-
gnuplot_cmd(h, "d_width=(gap_width_relative+total_box_width_relative)*dx/2.");
145141

146142
gnuplot_cmd(h,"list = ''");
147143
gnuplot_cmd(h,"index(w) = words(substr(list, 0, strstrt(list, w)-1))");
@@ -153,24 +149,37 @@ void configure_handle(gnuplot_ctrl * h, int number_of_events, int number_of_ele
153149

154150
gnuplot_cmd(h, "set term png truecolor");
155151
gnuplot_cmd(h, "set grid");
156-
gnuplot_cmd(h, "set boxwidth total_box_width_relative/n relative");
152+
//
157153
gnuplot_cmd(h, "set style fill transparent solid 0.5 noborder");
158154

159155

160156
gnuplot_cmd(h, "set term png size %d,%d", res_x, res_y);
161157

162158
gnuplot_cmd(h, "set ylabel \"Number of occurrences\"");
163159

160+
if(number_of_elements==1){
161+
float x_top = 0.7+number_of_events/10.0;
162+
float x_low = -0.7;
163+
//printf("x_top = %.2f\nx_low = %.2f\n", x_top, x_low);
164+
gnuplot_cmd(h, "set xrange [%.2f:%.2f]", x_low, x_top);
165+
gnuplot_cmd(h, "total_box_width_relative=0.3");
166+
gnuplot_cmd(h, "gap_width_relative=0.1");
167+
gnuplot_cmd(h, "d_width=(gap_width_relative+total_box_width_relative)*dx/2.");
168+
gnuplot_cmd(h, "set boxwidth total_box_width_relative/n");
169+
}
170+
else {
171+
gnuplot_cmd(h, "total_box_width_relative=0.3");
172+
gnuplot_cmd(h, "gap_width_relative=0.1");
173+
gnuplot_cmd(h, "d_width=(gap_width_relative+total_box_width_relative)*dx/2.");
174+
gnuplot_cmd(h, "set boxwidth total_box_width_relative/n relative");
175+
}
164176

165-
/*
166-
gnuplot_cmd(h, "set xrange [-1:%d]", number_of_elements);
167-
*/
168-
gnuplot_cmd(h, "set xtics out");
169-
gnuplot_cmd(h, "set xtics nomirror");
170-
gnuplot_cmd(h, "set xtics autofreq");
177+
//gnuplot_cmd(h, "set xtics out");
178+
//gnuplot_cmd(h, "set xtics nomirror");
179+
//gnuplot_cmd(h, "set xtics autofreq");
171180
gnuplot_cmd(h, "set xtics font \"monospace,%d\"", tics_font_size);
172181
gnuplot_cmd(h, "set tic scale 0");
173-
gnuplot_cmd(h, "set grid");
182+
gnuplot_cmd(h, "set grid noxtics");
174183

175184
gnuplot_cmd(h, "set label at character 1,1 \"Generated with Papify\"");
176185
gnuplot_cmd(h, "set format y \"%%.0se%%S\"");
@@ -616,7 +625,7 @@ event_acum_for_actor* process_data (char* path_todir, char* path_tofile, char* f
616625
//adding to totals per actor
617626
int label_set = 0;
618627
datafile = fopen(path_to_totals,"r");
619-
if(fgets(buf,1500,datafile)==NULL);// perror("");
628+
if(fgets(buf,1500,datafile)==NULL);//nothing wrong here!
620629
if(strstr(buf,"Actor;")!=NULL) label_set = 1;
621630
fclose(datafile);
622631

0 commit comments

Comments
 (0)