diff --git a/opppy/plot_dictionary.py b/opppy/plot_dictionary.py index e06760c..977d635 100644 --- a/opppy/plot_dictionary.py +++ b/opppy/plot_dictionary.py @@ -146,7 +146,7 @@ def plot_dict(self, args, dictionaries, data_names): print('# ', header_xlabel, header_ylabel, file=outputfile) for x_value, y_value in zip(x, y): - outstring = "%.9e"%(x_value*scale_x)+" %.9e"%(y_value*scale_y)+"\n" + outstring = "%.9e"%(x_value)+" %.9e"%(y_value)+"\n" outputfile.write(outstring) data_name = '' if(args.data_file_name is not None): @@ -199,12 +199,13 @@ def plot_dict(self, args, dictionaries, data_names): if(len(x)>0): last_x.append(x[-1]) last_y.append(y[-1]) + + if(args.font_size is not None): + PyPloter.rcParams.update({'font_size':args.font_size}) if(args.plot_max): last_y.append(sum(sorted(y,reverse=True)[0:2])/3.0) last_x.append(x[-1]) - elif(args.plot_arrival): - continue elif(data_line_color != '' and data_line_type != ''): PyPloter.plot(x,y,label = data_name, linestyle = data_line_type, color = data_line_color) elif(data_line_color != '' ): @@ -214,17 +215,22 @@ def plot_dict(self, args, dictionaries, data_names): else: PyPloter.plot(x,y,label = data_name) + interp_x = x[0] if(args.plot_arrival): + args.plot_arrival = False last_x = x[0] last_y = y[0] for x_value, y_value in zip(x,y): if(y_value>args.y_exceeds_value): + args.plot_arrival = True dy = (args.y_exceeds_value - last_y)/(y_value - last_y) interp_x = last_x + dy*(x_value-last_x) - print(data_name, "first exceeds ", y_exceeds_value, " at ", interp_x) + print(data_name, "first exceeds ", args.y_exceeds_value, " at ", interp_x) break last_x = x_value last_y = y_value + if(not args.plot_arrival): + print("WARNING: y never exceeds y_exceeds_value="+str(args.y_exceeds_value)); if(args.find_max_y): print(data_name, "max y value ", x[y.index(max(y))], max(y)) @@ -233,9 +239,13 @@ def plot_dict(self, args, dictionaries, data_names): if(args.last_point_only): PyPloter.plot(last_x, last_y, label = data_name) - elif(args.plot_arrival or args.plot_max): - print(last_x, last_y) - PyPloter.plot(last_x, last_y, label = data_name) + elif(args.plot_arrival): + color=PyPloter.gca().lines[-1].get_color() + PyPloter.plot(interp_x, args.y_exceeds_value, linestyle=None, color=color, marker='o', label = data_name + " exceeds y="+str(args.y_exceeds_value)+" @ x="+str(interp_x)) + elif(args.plot_max): + print("max y= "+str(last_y)+" @ x="+str(last_x)) + color=PyPloter.gca().lines[-1].get_color() + PyPloter.plot(last_x, last_y, linestyle=None, color=color, marker='x', label = data_name + " max y="+str(last_y)+" @ x="+str(last_x)) if(args.x_label is not None): PyPloter.xlabel(args.x_label) diff --git a/opppy/plotting_help.py b/opppy/plotting_help.py index eae315b..a65cd4c 100644 --- a/opppy/plotting_help.py +++ b/opppy/plotting_help.py @@ -276,6 +276,7 @@ def add_plot_options(parser): parser.add_argument('-lpo','--last_point_only', dest='last_point_only', help='only plot the last data point', nargs='?', type=bool, default=False, const=True ) parser.add_argument('-ltv','--last_time_value', dest='last_time_value', help='only plot the last time value', nargs=1, type=float) parser.add_argument('-fr','--figure_resolution', dest='figure_resolution', help='figure resolution in dpi', nargs='?', type=float, default=300.0) + parser.add_argument('-fs','--font_size', dest='font size', help='set the plot font size', type=float, default=None, nargs="?") parser.add_argument('-yev','--y_exceeds_value', dest='y_exceeds_value', help='y arrival value', nargs=1, type=float, default=0.0) parser.add_argument('-sy','--scale_y', dest='scale_y', help='scale y values', type=float, default=[], action="append") parser.add_argument('-sx','--scale_x', dest='scale_x', help='scale x values', type=float, default=[], action="append") @@ -301,6 +302,7 @@ def add_2d_plot_options(parser): parser.add_argument('-xlab','--xlab', dest='x_label', help='x axis label') parser.add_argument('-ylab','--ylabl', dest='y_label', help='y axis label') parser.add_argument('-fr','--figure_resolution', dest='figure_resolution', help='figure resolution in dpi', nargs='?', type=float, default=300.0) + parser.add_argument('-fs','--font_size', dest='font size', help='set the plot font size', type=float, default=None, nargs="?") parser.add_argument('-sv','--scale_value', dest='scale_value', help='scale values', type=float, default=1.0) parser.add_argument('-sx','--scale_x', dest='scale_x', help='scale x values', type=float, default=1.0) parser.add_argument('-sy','--scale_y', dest='scale_y', help='scale y values', type=float, default=1.0)