I am well experienced in the C languages, but for a project that I have been assigned in one of my classes, I am considering using it as a project to introduce me into Python. I have never used Python before, but I have done some research, and it is very clear that GUI design and Visualizations come very easy to Python; however, I have been unable to find any libraries on threads.
My project is going to have two threads checking an object/class to see if a bool is set so that it can operate on some data and once it's turn is finished it will flag the other thread to operate on that same data. There will be several hundred logged data points on a graph that I will need to display graphically.
My questions are the following:
Does Python have specific libraries that could help me display graphs with hundreds of points easily? If so, which would you recommend for a beginner in Python?
Which thread libraries are best for beginners in Python?
Thank you all for any help in this matter.
igraph is good for graph visualisation. If you mean plotting points, use matplotlib.
threading module is built-in with python standard library.
You probably don't want threads in Python, as only one can run at a time. Search GIL (here or Google). There are modules like multiprocessing that allow easy use of multiple process based concurrency. The following creates two processes that print the strings passed in the args keyword arg. The biggest problem with multiprocessing is that, because it is multiprocess (and the processes have separate address spaces), shared objects have to 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 graphing, see matplotlib. You can use it as a stand alone to just plot and show or you can embed it in a larger GUI library like QT. The following plots 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 pretty much any type of graph you can think of (scatter, histo, 3d surf/frame, contour, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With