def typlot(*args, **kwargs): """Create a time plot of the given variable""" _require_plot_mode(tplot_mod.TYCURVE) # If args not specified then get args using asynchronous input if not args: yield "Y VARIABLE " args = kwargs["io_helper"].get_input().split() if not args: args = [" "] args = list(args) var = _find_variable_or_raise_exception(state.reader, args.pop(0)) if var.type == GLOBAL_VARIABLE: if args: blot_common.print_blot_warning("Extra tokens after global " "variable name ignored.") c = tplot_mod.Curve(var) state.tplot.add_curve(c) state.tplot.print_show() return if not args: raise BlotishError("Expected node/element number") s = " ".join(args) try: selected_ids = number_list_parser.parse_number_list(s, int) except number_list_parser.Error, err: raise BlotishError(err)
if not args: raise BlotishError("Expected node/element number") s = " ".join(args) try: selected_ids = number_list_parser.parse_number_list(s, int) except number_list_parser.Error, err: raise BlotishError(err) uniq = dict() selected_ids = [ uniq.setdefault(i, i) for i in selected_ids if i not in uniq ] for id in selected_ids: c = tplot_mod.Curve(var, id) state.tplot.add_curve(c) state.tplot.print_show() def _require_plot_mode(mode): """Check if the current tplot mode is the given mode. If there is a mismatch raise a BlotishError.""" current_mode = state.tplot.get_current_curve_mode() if current_mode is not None: if mode != current_mode: raise BlotishError( "Time curves and X-Y curves must be defined separately") @_subprogram("tplot")