do me a favor?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sige0008
    New Member
    • Sep 2006
    • 13

    #1

    do me a favor?

    Hi folks:

    my sample data looks like following( tab-delimited):

    Education Sex Experience Wage
    10 1 5 10
    5 1 10 9
    15 0 10 15

    Currently I am doing a project that will need Python/Tk as well as VTK(Visualizati on Toolkit) for image processing and visualization.

    I want to plot one of variable in x-axes and one of variable in y-axes, and color by one of variables

    I thought it may be a good idea to read data into python array (eg. each record into rows, attributes in columns) and then use a for loop to find the position of each points and color them.

    Can anyone do me this big favour? give me some advices, thanks:-)
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    I don't know if VTK has plotting functions built in, so...
    I haven't gotten into it yet, but I'm planning on using sciPy for my data plotting needs. Yes, you have to learn a new package, but you don't have to write plotting functions.

    Comment

    • sige0008
      New Member
      • Sep 2006
      • 13

      #3
      hi there:

      I have another question about how to create a combo box (or listbox) in this project. can you help me please if you know :-)

      Thanks

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Code:
        import Tkinter as Tk
        
        aList_of_data = [1,2,3,4]
        
        if __name__ == "__main__":
            root = Tk.Tk()
            mainFrame = Tk.Frame(root)
            mainFrame.pack()
            lb = Tk.Listbox(mainFrame)
            lb.config(bg="white")
            lb.pack()
        
            lb.insert(0, *aList_of_data )
            
            root.mainloop()

        Comment

        • sige0008
          New Member
          • Sep 2006
          • 13

          #5
          Thanks:-)

          I thought there is no combo box in TK, is that right???

          So I can only use list in my project.

          Comment

          • bartonc
            Recognized Expert Expert
            • Sep 2006
            • 6478

            #6
            No combobox in tk is correct. I built a really fancy combobox that requires PIL to handle the graphics to make it look more native on Windows. It uses a popup menu to get an item out of list that is read in when it is created and is also editable. If you would like a stripped down version, I could probalby have it working in a day or so.

            Comment

            • sige0008
              New Member
              • Sep 2006
              • 13

              #7
              Thanks, I solved this problem:-) I give your a link, you may intereste that:

              Python megawidgets(pmw )
              http://sourceforge.net/projects/pmw

              Description:
              A toolkit for building high-level compound widgets in Python using the Tkinter module. It contains a set of flexible and extensible megawidgets, including notebooks, comboboxes, selection widgets, paned widgets, scrolled widgets and dialog windows.

              By the way:
              After reading the data set, I want to display points into an axes. For example, each point should have two values(educatio n, experience) ie(10,20). Do you have any ideas for coding axes?? Thanks:-)

              My final display should be something looks like the following picture:

              my sample interface

              Comment

              • bartonc
                Recognized Expert Expert
                • Sep 2006
                • 6478

                #8
                I recently switched from Tk to wxPython for a very complete and native look on Windows, but thank you for the link.

                gnuplot module looks like it might work for you.

                Comment

                • sige0008
                  New Member
                  • Sep 2006
                  • 13

                  #9
                  Thanks:-)

                  I have learned a lots from you, thanks

                  but I still have one question about adding multiple scalars to a single points in vtk, do you have any tips. I thought I should do something about data attribute, but I am not sure how to do it.

                  Thanks

                  Comment

                  • bartonc
                    Recognized Expert Expert
                    • Sep 2006
                    • 6478

                    #10
                    Perhaps you can find a copy of Hans Petter Langtangen's book "Python Scripting fo Computational Science" where all this kind of thing is taught.

                    Comment

                    • sige0008
                      New Member
                      • Sep 2006
                      • 13

                      #11
                      I found the solution, thanks anyway:-)

                      you have given me a lots help, thanks! I really appreciate what you did

                      Comment

                      Working...