[Matplotlib-users] gps-satellite sky-plot
Hi All, i'm starting to learn matplotlib, for my study i need to parse the nmea sentence from a gps and plot a "sky graphic" to plot satellite visibility. (i tried to write code from scratch ... it works but my teacher suggest me to not reinvent the well, so, to have a good nema parser, i installed gpsd ... it has in the source code a nice python code that allow me to retrieve satellite constallation iformation). now i need to learn how to produce a sky plot, have you any suggestion on how to produce such kind of graphic ? thanks to all for any suggestion! Massimo. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] gps-satellite sky-plot
Hi Jef, please apologize me for the delay i had days without internet connection :-/ sorry if i gived you a bad explanation ... for sky plot i means plot like : http://www.tpub.com/content/armyengineer/en0593a/en0593a0209.htm the data i'm receiving from the gps device are : PRN = satellite ID EL = ELevation (integer 0-90) AZ = Azimuth (integer 0-359) Ss = Signal-Strenghts (decibels) Used = (1,0) for each satellite visible at the moment, i receive data for each second. i'm printing the data in an html table http://img43.imageshack.us/i/immagine3ftd.png/ but i tring to learn how to use matplotlib to display the data in a "sky-plot" (i don't know the real name of this polar-diagram) i gived a look at matplotlib tutorial pages .. and i find really usefull the "web-plot" example ... i'll follow that way but the real problem is : i don't know the math formulae and matplotlib syntax needed to create a such kind of plot. thanks for any suggestion! regards, Massimo. Il giorno 03/lug/09, alle ore 03:34, Jeff Whitaker ha scritto: Massimo Di Stefano wrote: Hi All, i'm starting to learn matplotlib, for my study i need to parse the nmea sentence from a gps and plot a "sky graphic" to plot satellite visibility. (i tried to write code from scratch ... it works but my teacher suggest me to not reinvent the well, so, to have a good nema parser, i installed gpsd ... it has in the source code a nice python code that allow me to retrieve satellite constallation iformation). now i need to learn how to produce a sky plot, have you any suggestion on how to produce such kind of graphic ? Massimo: I've no idea what a "sky plot" is. Can you point us to an example? -Jeff thanks to all for any suggestion! Massimo. -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] display image as (r, g, b) from a (3xMxN) nympy.array
Hi All, i've data store in a multydimension numpy.array, it is composed by 3 MxN normalized (0 - 1) array but tring to display it using "imshow" i get an error, " TypeError: Invalid dimensions for image data " please can you help me to fix this problem ? my data is : In [119]: dd[0] Out[119]: array([[[ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], ..., [ 0.22834646, 0.39370079, 0.38976378, ..., 0.2519685 , 0.25590551, 0.38582677], [ 0.30708661, 0.25984252, 0.30314961, ..., 0.2480315 , 0.25984252, 0.37401575], [ 0.58661417, 0.62598425, 0.5984252 , ..., 0.2480315 , 0.2519685 , 0.32283465]], [[ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], ..., [ 0.17322835, 0.37401575, 0.4015748 , ..., 0.27952756, 0.27559055, 0.42519685], [ 0.30314961, 0.24409449, 0.30314961, ..., 0.26771654, 0.27165354, 0.38976378], [ 0.57086614, 0.61811024, 0.5984252 , ..., 0.28346457, 0.26771654, 0.34251969]], [[ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], [ 1., 1., 1., ..., 1., 1., 1.], ..., [ 0.19685039, 0.34251969, 0.37795276, ..., 0.2519685 , 0.25984252, 0.34251969], [ 0.27165354, 0.21653543, 0.27559055, ..., 0.2519685 , 0.26377953, 0.30708661], [ 0.57480315, 0.63385827, 0.58661417, ..., 0.26377953, 0.25590551, 0.29527559]]]) In [120]: len(dd[0]) Out[120]: 3 In [121]: dd[0].shape Out[121]: (3, 2058, 2607) In [122]: matplotlib.pyplot.imshow(dd[0]) Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.6/site-packages/matplotlib/pyplot.py", line 2035, in imshow ret = ax.imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs) File "/Library/Python/2.6/site-packages/matplotlib/axes.py", line 6272, in imshow im.set_data(X) File "/Library/Python/2.6/site-packages/matplotlib/image.py", line 372, in set_data raise TypeError("Invalid dimensions for image data") TypeError: Invalid dimensions for image data thanks for any help!!! Massimo.-- Download IntelĀ® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bar plot (autofmt_xdate and left-right margins )
Hi All i'm bring to do simple bar plot formatting the xlabe as 'date' using a syntax like : fig.autofmt_xdate(bottom=0.1) but something is wrong in my code, please have you any hints on ghow to proper display the dates (Year) along the x axis and how to leave a margin on the left and on the right of the plot? (my example has a margin only on the right, while the first bar is adjacent to the Y axis) ### import numpy as np import matplotlib.pyplot as plt x = np.array([1969,1970,1971,1972,1973,1974]) y = np.array([-3,10,23,-4,-5,6]) data = [x,y] print x print y def bar_plot(data, Yval, datamin=None, datamax=None): """ doc """ fig = plt.figure() fig.autofmt_xdate(bottom=0.1) ax1 = fig.add_subplot(211) x = data[0] y = data[1] if datamin != datamax != None : x = data[0][np.where((data[0]>=datamin) & (data[0]<=datamax))[0]] y = data[1][np.where((data[0]>=datamin) & (data[0]<=datamax))[0]] x_p = x[np.where(y>=0)[0]] y_p = y[np.where(y>=0)[0]] x_n = x[np.where(y<0)[0]] y_n = y[np.where(y<0)[0]] ax1.bar(x_n, y_n, facecolor='b') ax1.bar(x_p, y_p, facecolor='r') ax1.grid(True) ax1.set_xlabel('Year') ax1.set_ylabel(Yval) ax1.set_title(Yval) ax1.axhline(0, color='black', lw=1) plt.show() bar_plot(data, 'Var', datamin=1970, datamax=1973) ### -- This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bar plot (autofmt_xdate and left-right margins )
i modified the code as follow : def bar_plot(data, Yval, datamin=None, datamax=None): """ doc """ x = data[0] y = data[1] # reduce dataset based on min max date if datamin != datamax != None : x = data[0][np.where((data[0]>=datamin) & (data[0]<=datamax))[0]] y = data[1][np.where((data[0]>=datamin) & (data[0]<=datamax))[0]] # index for labeling xp = np.where((y<=0))[0] xn = np.where((y>0))[0] xx = np.where((y>0) | (y<=0))[0] # extract positive and negative values x_p = x[np.where(y>=0)[0]] y_p = y[np.where(y>=0)[0]] x_n = x[np.where(y<0)[0]] y_n = y[np.where(y<0)[0]] # start plotting code fig = plt.figure(figsize=(15,5)) width = 0.7 plt.autoscale(enable=True, axis='both', tight=True) plt.bar(xn, y_n, width, color='blue', lw=2) plt.xticks(xx + (width/1.2), x) plt.autoscale(enable=True, axis='both', tight=True) plt.bar(xp, y_p, width, color='red', lw=2) plt.title(Yval) fig.autofmt_xdate() plt.xlabel("Year") plt.ylabel(Yval) plt.axhline(0, color='black', lw=2) plt.grid(True) Il giorno Mar 31, 2012, alle ore 10:21 PM, Massimo Di Stefano ha scritto: > > Hi All > > i'm bring to do simple bar plot formatting the xlabe as 'date' using a > syntax like : fig.autofmt_xdate(bottom=0.1) > but something is wrong in my code, please have you any hints on ghow to > proper display the dates (Year) along the x axis > and how to leave a margin on the left and on the right of the plot? (my > example has a margin only on the right, while the first bar is adjacent to > the Y axis) > > > ### > > import numpy as np > import matplotlib.pyplot as plt > > x = np.array([1969,1970,1971,1972,1973,1974]) > y = np.array([-3,10,23,-4,-5,6]) > data = [x,y] > > print x > print y > > > > > def bar_plot(data, Yval, datamin=None, datamax=None): >""" doc """ >fig = plt.figure() >fig.autofmt_xdate(bottom=0.1) >ax1 = fig.add_subplot(211) >x = data[0] >y = data[1] >if datamin != datamax != None : >x = data[0][np.where((data[0]>=datamin) & (data[0]<=datamax))[0]] >y = data[1][np.where((data[0]>=datamin) & (data[0]<=datamax))[0]] >x_p = x[np.where(y>=0)[0]] >y_p = y[np.where(y>=0)[0]] >x_n = x[np.where(y<0)[0]] >y_n = y[np.where(y<0)[0]] >ax1.bar(x_n, y_n, facecolor='b') >ax1.bar(x_p, y_p, facecolor='r') >ax1.grid(True) >ax1.set_xlabel('Year') >ax1.set_ylabel(Yval) >ax1.set_title(Yval) >ax1.axhline(0, color='black', lw=1) >plt.show() > > bar_plot(data, 'Var', datamin=1970, datamax=1973) > > ### -- This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] sampledoc sphinx-tutorial (missed link)
Hi All, I'm trying to access to the sampledoc tutorial, but seems it is no more on git/sourceforge, i tried at the link : http://matplotlib.sourceforge.net/sampledoc/ do you know where can i find it ? Thanks! Massimo. -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib and large array
Hi All, i need to work with a relative large images "60 mb" (single band geotiff file) i store it in python as a numpy array using python-gdal, the array dinension is (7173 X 7924) single band image, but tring to display it with matshow/imageshow or other matplotlib functions i have that python freeze itself and is not able to load the image. if i use a subset of the image, i 'm able to display it or at least i hade to reduce its resolution using hacks like : reduced_array = array[::3,::3] i don't need full resolution dataset when the image is displaied with a full "zoom out" so the reduction " reduced_array = array[::3,::3] " is good to show the complete image but when i zoom in the image i obviously lost data (less resolution) what do you use to display large dataset ? i'm thinking about a "piramid" with multy array based on the different zoom levels .. but maybe this idea is not so cool. someone already has developed similar code ? thanks to All for any suggestion! Regards, Massimo -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] display each images from a directory
Hello All, i'm tring to write python code to display images from a directory .. but i'm not able to learn how to use the matplotlib events to handle how the images will be displaied. simpli i need to pass to the code the path to directory where i have several tiff files and disply them one at time using a key event. to display a single image i'm using somethin like : #!/usr/bin/env python from pylab import * try: import Image except ImportError, exc: raise SystemExit("PIL must be installed to run this example") import glob def dispimg(input): image = Image.open(input) im = imshow(image, origin='lower') show() ### i tried to define a key action like : def onpress(event): if event.key=='a': fig.canvas.draw() # and set my directory with : fig = figure() fig.canvas.mpl_connect('key_press_event', onpress) TIFFS = glob.glob("/home/habcam/habcamdata/20100820_1840/*.tif") print "num TIFFS %d" % len(TIFFS) ## but i'm not able to learn how to plot them and update the displayed image using the key bindings : for tif in TIFFS: print tif show() thanks a lot for Any help! Massimo. -- Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] adjust axis to display array values
Hello All, i'm plotting a 3d colored surface using a 4D array that comes from a .mat file using this code : import scipy.io as sio import pylab as p import mpl_toolkits.mplot3d.axes3d as p3 def loadmatfile(matfile): matdata = sio.loadmat(matfile) return matdata def plot3dcolor(matfile): data = loadmatfile(matfile) x = data['X_depth'] y = data['Y_depth'] z = -data['Z_depth'] c = data['Z_compl'] fig=p.figure() ax = p3.Axes3D(fig) cmap = p.get_cmap('jet') norm = p.Normalize(c.min(), c.max()) colors = cmap(norm(c)) ax.plot_surface(x, y, z, rstride=10, cstride=10, facecolors=colors) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') print x,y p.show() matfile = '/Users/epy/Desktop/complexity_depth_grid1.mat' plot3dcolor(matfile) the results is nice : http://img831.imageshack.us/f/schermata20110204a14542.png/ but as you can see, the mouse cursor shows me the x,y values (they are longitude and latitude) but on the axis i have them starting from 0 ... how can i change the axis to display the lon-lat coordinates ? thanks a lot for any help! Massimo. -- The modern datacenter depends on network connectivity to access resources and provide services. The best practices for maximizing a physical server's connectivity to a physical network are well understood - see how these rules translate into the virtual world? http://p.sf.net/sfu/oracle-sfdevnlfb ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] adjust axis to display array values
Hi Benjamin, have you reied the mat file ? i treid using a simple python array in a 2d plot and i'm having the same behavioure the x,y coordinates are displayed ok when the mouse roll over the graph but they are wrong in the axis labels. Il giorno 05/feb/2011, alle ore 09.23, Massimo Di Stefano ha scritto: > Hi Benjamin, > > The mat file is : > > > > few kbyte :-) > > > thnaks! > > Massimo > > > > Il giorno 04/feb/2011, alle ore 19.41, Benjamin Root ha scritto: > >> On Friday, February 4, 2011, Massimo Di Stefano >> wrote: >>> Hello All, >>> >>> >>> i'm plotting a 3d colored surface using a 4D array that comes from a .mat >>> file >>> using this code : >>> >>> >>> import scipy.io as sio >>> import pylab as p >>> import mpl_toolkits.mplot3d.axes3d as p3 >>> >>> def loadmatfile(matfile): >>> matdata = sio.loadmat(matfile) >>> return matdata >>> >>> >>> def plot3dcolor(matfile): >>> data = loadmatfile(matfile) >>> x = data['X_depth'] >>> y = data['Y_depth'] >>> z = -data['Z_depth'] >>> c = data['Z_compl'] >>> fig=p.figure() >>> ax = p3.Axes3D(fig) >>> cmap = p.get_cmap('jet') >>> norm = p.Normalize(c.min(), c.max()) >>> colors = cmap(norm(c)) >>> ax.plot_surface(x, y, z, rstride=10, cstride=10, facecolors=colors) >>> ax.set_xlabel('X') >>> ax.set_ylabel('Y') >>> ax.set_zlabel('Z') >>> print x,y >>> p.show() >>> >>> >>> matfile = '/Users/epy/Desktop/complexity_depth_grid1.mat' >>> plot3dcolor(matfile) >>> >>> >>> >>> the results is nice : >>> >>> http://img831.imageshack.us/f/schermata20110204a14542.png/ >>> >>> >>> but as you can see, the mouse cursor shows me the x,y values (they are >>> longitude and latitude) >>> but on the axis i have them starting from 0 ... >>> >>> how can i change the axis to display the lon-lat coordinates ? >>> >>> >>> thanks a lot for any help! >>> >>> Massimo. >>> >>> >> >> I suspect what is happening is that the axes label numbers are right, >> but is not showing the offset information. The display of offset data >> in a 3d plot is a new feature that exists only in the development >> branch. >> >> To confirm this, could you send me your may file (if it is small) so >> that I can try out your script? >> >> Ben Root > -- The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] refresh 3dplot
hello All have you never tried to embed a matplotlib 3d graph inside pyqt ? i'm tring to do it .. but i've problenms to refresh my plot. The 3d data are displayed ok inside a pyqt simple widget, but if i try to redraw the image (re-call the on_draw function) ... i have it overlay the previouse one. If i add "clear()" at begin of my "on_draw" action, the plot is update correctly ... and each "on_draw" action give me the correct results ... but then i'm no more able to move the 3d plot view (but i can only zoom in/out the scene) the code i'm using is : http://paste.debian.net/106890 at line 22 there is a "def erase(self):" function if i connect it to the plot i have the image is correctly redraw .. but then i lost the 3d actions can you give it a try ? seems thast the "clear()" action broke something ... thanks a lot for any help to try it .. i've upload the .mat file (just few kbytes) it is available at : http://www.geofemengineering.it/data/complexity_depth_grid1.mat Thank you! Massimo. -- The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [PyQt] refresh 3dplot
ok :-) i find a solution .. maybe correct : in the __init__ i added : self.a = None then in "on_draw" : if self.a is not None: self.axes.collections.remove(self.a) self.a = self.axes.plot_surface(x, y, z, rstride=res, cstride=res, facecolors=colors) now the plot is refreshed ok :-) Il giorno 08/feb/2011, alle ore 10.35, Massimo Di Stefano ha scritto: > hello All > > have you never tried to embed a matplotlib 3d graph inside pyqt ? > > i'm tring to do it .. but i've problenms to refresh my plot. > > The 3d data are displayed ok inside a pyqt simple widget, > but if i try to redraw the image (re-call the on_draw function) ... > i have it overlay the previouse one. > > If i add "clear()" at begin of my "on_draw" action, > the plot is update correctly ... and each "on_draw" action give me the > correct results ... > but then i'm no more able to move the 3d plot view (but i can only zoom > in/out the scene) > the code i'm using is : http://paste.debian.net/106890 > at line 22 there is a "def erase(self):" function > if i connect it to the plot i have the image is correctly redraw .. but then > i lost the 3d actions > can you give it a try ? > > seems thast the "clear()" action broke something ... thanks a lot for any help > to try it .. i've upload the .mat file (just few kbytes) > it is available at : > > http://www.geofemengineering.it/data/complexity_depth_grid1.mat > > > Thank you! > > Massimo. > > ___ > PyQt mailing listp...@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users