def graphPlot(workspace, again, tokens): """Function for plotting graphs in 2D and 3D space 2D graphs are plotted for expression in one variable and equations in two variables. 3D graphs are plotted for expressions in two variables and equations in three variables. Arguments: workspace {QtWidgets.QWidget} -- main layout Returns: graphVars {list} -- variables to be plotted on the graph func {numpy.array(2D)/function(3D)} -- equation converted to compatible data type for plotting variables {list} -- variables in given equation again {bool} -- True when an equation can be plotted in 2D and 3D both else False Note: The func obtained from graphPlot() function is of different type for 2D and 3D plots. For 2D, func is a numpy array, and for 3D, func is a function. """ if tokens is None: axisRange = workspace.axisRange tokens = workspace.eqToks[-1] else: axisRange = [10, 10, 10, 30] eqType = getTokensType(tokens) LHStok, RHStok = getLHSandRHS(tokens) variables = sorted(getVariables(LHStok, RHStok)) dim = len(variables) if (dim == 1) or ((dim == 2) and eqType == "equation"): if again: variables.append('f(' + variables[0] + ')') graphVars, func = plotIn3D(LHStok, RHStok, variables, axisRange) else: graphVars, func = plotIn2D(LHStok, RHStok, variables, axisRange) if dim == 1: variables.append('f(' + variables[0] + ')') elif (dim == 2 and eqType == "expression") or ((dim == 3) and eqType == "equation"): graphVars, func = plotIn3D(LHStok, RHStok, variables, axisRange) if dim == 2: variables.append('f(' + variables[0] + ',' + variables[1] + ')') else: return [], None, None return graphVars, func, variables