A look at getting in Python specifically for a project that includes streams and graphs

I'm good with C languages, but for a project that has been assigned in one of my classes, I see it as a project to introduce me to Python. I've never used Python before, but I've done some research and it's very clear that GUI design and rendering are very Python-friendly; however, I was unable to find libraries in streams.

My project will have two threads inspecting an object / class to determine if bool is set so that it can work with some data, and once it finishes, it will note that another thread is working with the same data. The graph will display several hundred logged data points which I will need to display graphically.

I ask the following questions:

  • Does Python have specific libraries that can help me display graphs of hundreds of points easily? If so, what would you recommend for those new to Python?

  • Which threading libraries are best for beginners in Python?

Thanks everyone for any help on this issue.

+3


source to share


2 answers


You probably don't need threads in Python, as only one can run at a time. Search the GIL (here or Google). There are modules such as multiprocessing

that make it easy to use multiple concurrency based processes. The following creates two processes that print the lines passed to the args keyword arg. The biggest problem with multiprocessing is that because it is a multiprocessor (and processes have separate address spaces), shared objects must be handled explicitly.

import multiprocessing as mp

def f(name):
  print name

p = mp.Process(target=f, args=('bob',))
q = mp.Process(target=f, args=('jeff',))
p.start()
q.start()
p.join()
q.join()

      

For plotting see matplotlib. You can use it on its own to just draw and show, or you can embed it in a large GUI library like QT. The following plot displays a line in matplotlib.



import matplotlib as plt

X = [0, 1, 2]
Y = [0, 1, 2]
plt.plot(X, Y)
plt.show()

      

It can also do just about any type of graph you can think of (scatter, histo, 3D surfing / border, outline, etc.).

+1


source


igraph is good for graph rendering. If you mean plotting points, use matplotlib.



the streaming module is built into the python standard library.

+4


source







All Articles