Topic: Plugin for Python

I have Python 3.7 installed but Graph 4.4.2 does not recognize this as a plugin.
Q1. How do I get Graph to plot functions from Python?
Q2. Do I have to use matplotLib to make this work?
Thanks, gordc

Re: Plugin for Python

Graph 4.4.2 uses Python 3.2 for plugin support. However the latest beta version of Graph 4.5 uses Python 3.7. With the beta version you also don't have to install Python yourself as it comes bundled with Graph.

Re: Plugin for Python

Thanks. Before I install 4.4.5, I would like to know how, from the user's viewpoint, how Graph interfaces with Python 3.7. Does Graph replace matplotlib or are those graphing routines re-directed to Graph? matplotlib routines have a fairly steep learning curve so any simplification would be welcome. Just need an example of plotting Python with Graph 4.4.5.
gordc

Re: Plugin for Python

Graph doesn't use matplotlib. There are some example plugins installed with Graph, and you are welcome to ask if you have any questions.

The documentation of the Python interfcae to Graph, which is installed with Graph, can also be found here:
https://www.padowan.dk/doc/PluginDoc/

The following shows how to add a function from Python:

F=Graph.TStdFunc("x^2+3x-5")
Graph.FunctionList.append(F)

Re: Plugin for Python

Thanks, I have installed the beta 4.5 and Python 3.7 is included. The example you gave works perfectly. I realize that time is needed to give help; if someone could point me to the Function List (which may be already on your home page) and how to use it.
gordc

Re: Plugin for Python

There is some documentation here: https://www.padowan.dk/doc/PluginDoc/Gr … l#id500386
Graph.FunctionList is basically just a list with all items shown in the function list in Graph. You can add, remove and delete functions, tangents, relations, etc. to Graph.FunctionList to have it reflect in the list in Graph.

7 (edited by gordc 2018-12-04 15:19:57)

Re: Plugin for Python

For those members who, like myself, are much more comfortable with Visual Basic and want to use Graph to display data, I suggest two methods to transfer point data.
1). Using a file. In VB, fill an array with data and write to a file in text format.
    Here is an example of generating 2 files for magnitude and phase of a lowpass filter:-
        Dim mag(80) As String
        Dim phz(80) As String
        Dim indx = 0
        For w = 0.125 To 10 Step 0.125
            Dim c1 As New Complex(1, w)   values
            Dim c2 As New Complex(1, 5 * w)
             mag(indx) = w.ToString & "," & Complex.Abs(c1 /c2).ToString      'needs system.Numerics import and reference     
            phz(indx) = w.ToString & "," & ((c1 / c2).Phase*57.4).ToString      'to actually run this snippet
            indx += 1
        Next
        File.WriteAllLines("e:\plotmag.txt", mag)
        File.WriteAllLines("e:\plotphase.txt", phz)
        Console.ReadLine()

This is detailed but actual example. Note that data is converted from numeric to text format with the X data, then separator (comma), then Y data. Graph will also except a 'space' as the separator.
In Graph, access these point data files with an "import point data" command.

2).EDITED Dec4 (Listbox ref removed)
This uses Ctrl C from a VB Windows Form application.
EXample:-
Create a Forms app with a button, and a TextBox.
Enter the following code;-
Public Class Form1
    'use textbox to collect values then select values manually and copy (ctrl c)
    'example collects squares of numbers to use with Graph
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim j As Integer
        For j = 1 To 10
               TextBox1.AppendText(j.ToString & " " & j ^ 2.ToString & vbCrLf) 'multi-Line set to TRUE
        Next
    End Sub
End Class
After running the program select data from the TextBox, Copy (ctrl c) and paste into Graph "Insert Point Data"
Hope this will be useful.
Gord