Topic: Add Shade to a function

i wish to add shading to the function using python.
Help file tells
Creates a new shading object. It must be attached to a function to be plotted

how a shade object created to be attached to active function

Re: Add Shade to a function

You either need to create a new function or add the shading to an existing function. The following example will create a new function:

F = Graph.TStdFunc("sin x") # Create new function
Graph.FunctionList.append(F) # Add the function to the function list
S = Graph.TShading() # Create shading
F.ChildList.append(S) # Attach the shading to the function

3 (edited by anandstudy1973 2018-09-18 14:57:37)

Re: Add Shade to a function

Thanks Ivan

i want to define its boundary
like
S.From=0
S.To=1
and change the shadiing pattern with color.
also
add another function to the 2nd function box

Re: Add Shade to a function

You can find the documentation for the TShading class here:
https://www.padowan.dk/doc/PluginDoc/Gr … h.TShading

Here is an example that will create a shading between two functions. As you can see the values you can set are similar to the ones you can find in the Insert function dialog.

F = Graph.TStdFunc("sin x") # Create new function
Graph.FunctionList.append(F) # Add the function to the function list
F2 = Graph.TStdFunc("x+1") # Create a second new function
Graph.FunctionList.append(F2) # Add the second function to the function list

S = Graph.TShading() # Create shading
S.sMin = 0
S.sMax = 1
S.BrushStyle = 6 # 6=bsCross
S.Color = 0x008000 # Green
S.Func2 = F2
S.ShadeStyle = Graph.ssBetween
S.sMin2 = 0
S.sMax2 = 1
F.ChildList.append(S) # Attach the shading to the function
Graph.Redraw()

Re: Add Shade to a function

thanks