From regev81 at gmail.com Tue Dec 3 10:09:31 2019 From: regev81 at gmail.com (regev81) Date: Tue, 3 Dec 2019 08:09:31 -0700 (MST) Subject: [Matplotlib-users] Add and remove points to a scatter plot repeatedly Message-ID: <1575385771622-0.post@n5.nabble.com> I am trying to add and remove points to a scatter plot repeatedly, each time with a different set of points, while a wireframe plot is in the background. is there a way to do so with out closing the all figure window and the background wireframe plot? Thanks Here is my python code: import gdal from mpl_toolkits.mplot3d.axes3d import * import matplotlib.pyplot as plt from pathlib import Path #import the raster tif file and convert to 2d array dataset = gdal.Open("dem_demo.tif") dem_arr = dataset.ReadAsArray() #slicing #dem_arr[start row:end row,start col:end col] sliced_dem_arr = dem_arr[100:151,100:151] rowCount = sliced_dem_arr.shape[0] colCount = sliced_dem_arr.shape[1] #set the X, Y, Z arrays for plotting process rowArr = np.arange(1,rowCount+1) colArr = np.arange(1,colCount+1) X, Y = np.meshgrid(rowArr, colArr) Z = sliced_dem_arr #set 3d view ans labels ax = plt.axes(projection='3d') ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('z') ############plotting the dtm ######################## ###wireframe ax.plot_wireframe(X, Y, Z, color='green') #Add points #01 points_list = [(2,6),(30,14),(39,15)] for p in points_list: ax.scatter(p[0], p[1], sliced_dem_arr[p[0],p[1]], c = 'r') plt.show() #Add points #02 points_list2 = [(5,23),(24,4),(12,45)] for p in points_list2: ax.scatter(p[0], p[1], sliced_dem_arr[p[0],p[1]], c = 'r') plt.show() -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From selasley at icloud.com Tue Dec 3 15:34:53 2019 From: selasley at icloud.com (Scott Lasley) Date: Tue, 3 Dec 2019 15:34:53 -0500 Subject: [Matplotlib-users] Add and remove points to a scatter plot repeatedly In-Reply-To: <1575385771622-0.post@n5.nabble.com> References: <1575385771622-0.post@n5.nabble.com> Message-ID: <6AC2A913-56FB-42C7-873E-C8AD9B378748@icloud.com> You could use animation. See https://stackoverflow.com/questions/41602588/matplotlib-3d-scatter-animations Here is a short example based on the Matplotlib wireframe example (https://matplotlib.org/3.1.1/gallery/mplot3d/wire3d.html) and your two sets of points. This will work in a Jupyter notebook if you use the %matplotlib notebook magic command but the animation does not work with jupyter lab. import numpy as np from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt import matplotlib.animation def update_graph(num): # alternate between the 2 sets of points num = 3 * (num % 2) data = points[num:num+3] dots.set_data (data[:,0], data[:,1]) dots.set_3d_properties(data[:,2]) return dots, fig = plt.figure(figsize=(8,8)) ax = fig.add_subplot(111, projection='3d') # Plot a basic wireframe. X, Y, Z = axes3d.get_test_data(0.05) ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10, color='green') # set up the points to be plotted points_list = np.array([(2,6),(30,14),(39,15)]) points = np.append(points_list, Z[points_list[:,0], points_list[:,1]].reshape(3,1), 1) points_list2 = np.array([(5,23),(24,4),(12,45)]) points = np.append(points, np.append(points_list2, Z[points_list2[:,0], points_list2[:,1]].reshape(3,1), 1), 0) dots, = ax.plot(points[:,0][:3], points[:,1][:3], points[:,2][:3], linestyle="", marker="o", c='r') ani = matplotlib.animation.FuncAnimation(fig, update_graph, 2, interval=500, blit=True) plt.show() I ran the example with matplotlib 3.1.1 in python 3.8. Hth, Scott > On Dec 3, 2019, at 10:09 AM, regev81 wrote: > > I am trying to add and remove points to a scatter plot repeatedly, each time > with a different set of points, while a wireframe plot is in the > background. > is there a way to do so with out closing the all figure window and the > background wireframe plot? > > Thanks > > Here is my python code: > import gdal > from mpl_toolkits.mplot3d.axes3d import * > import matplotlib.pyplot as plt > from pathlib import Path > > #import the raster tif file and convert to 2d array > dataset = gdal.Open("dem_demo.tif") > dem_arr = dataset.ReadAsArray() > > #slicing > #dem_arr[start row:end row,start col:end col] > sliced_dem_arr = dem_arr[100:151,100:151] > rowCount = sliced_dem_arr.shape[0] > colCount = sliced_dem_arr.shape[1] > > #set the X, Y, Z arrays for plotting process > rowArr = np.arange(1,rowCount+1) > colArr = np.arange(1,colCount+1) > X, Y = np.meshgrid(rowArr, colArr) > Z = sliced_dem_arr > > #set 3d view ans labels > ax = plt.axes(projection='3d') > ax.set_xlabel('x') > ax.set_ylabel('y') > ax.set_zlabel('z') > > ############plotting the dtm ######################## > ###wireframe > ax.plot_wireframe(X, Y, Z, color='green') > > #Add points #01 > points_list = [(2,6),(30,14),(39,15)] > for p in points_list: > ax.scatter(p[0], p[1], sliced_dem_arr[p[0],p[1]], c = 'r') > plt.show() > > #Add points #02 > points_list2 = [(5,23),(24,4),(12,45)] > for p in points_list2: > ax.scatter(p[0], p[1], sliced_dem_arr[p[0],p[1]], c = 'r') > plt.show() > > > > > > -- > Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users From regev81 at gmail.com Tue Dec 3 16:19:28 2019 From: regev81 at gmail.com (regev81) Date: Tue, 3 Dec 2019 14:19:28 -0700 (MST) Subject: [Matplotlib-users] Add and remove points to a scatter plot repeatedly In-Reply-To: <6AC2A913-56FB-42C7-873E-C8AD9B378748@icloud.com> References: <1575385771622-0.post@n5.nabble.com> <6AC2A913-56FB-42C7-873E-C8AD9B378748@icloud.com> Message-ID: <1575407968771-0.post@n5.nabble.com> Thanks, Scott. But i create the scatter plots in runtime and i want to present them when i want by a function and not by a time interval. Is there a way to do so ? -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From viniciushenrique951 at hotmail.com Thu Dec 5 14:17:04 2019 From: viniciushenrique951 at hotmail.com (vinicius951) Date: Thu, 5 Dec 2019 12:17:04 -0700 (MST) Subject: [Matplotlib-users] Plot a graph using matplotlib.pyplot Message-ID: <1575573424337-0.post@n5.nabble.com> Hi, do you remember me? You help me days ago, and i wanna that you help me again if you don't mind. The code below is for plotting the graphs on my screen, but the visualization still not as expected. The axis-y is composed of words relatively larges, and the figure ends up cutting the words. The colors are not yet intuitive to understand. I would like that you give me some tips, help, guidance on how to improve the presentation of this result. Basically, with Pandas, i read a csv file, made up of several columns, among which I get the colum 'estado_fisico' and ploting in the graphic. def Condutor_estadofisico(): fig = plt.figure(figsize=(4, 10)) df_condutor = pd.read_csv('df_condutor.csv') x = df_condutor['estado_fisico'].value_counts().index y = df_condutor['estado_fisico'].value_counts().values a = plt.barh(x, y, color=colors, alpha=0.9) plt.legend(a, x, fontsize=4.8) for i, v in enumerate(y): plt.text(v + 3, i + .25, str(v), color='blue', fontweight='bold', fontsize=6.2) return fig -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From teksondada at gmail.com Thu Dec 5 23:14:06 2019 From: teksondada at gmail.com (tekson) Date: Thu, 5 Dec 2019 21:14:06 -0700 (MST) Subject: [Matplotlib-users] Same widht and height axis in matplotlib for every plot Message-ID: <1575605646452-0.post@n5.nabble.com> I need same size widht and height in every plot. I already asked this question in stackoverflow. Please help me; https://stackoverflow.com/questions/59187959/same-widht-and-height-axis-in-matplotlib-for-every-plot?noredirect=1#comment104614988_59187959 -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From for.mail at laposte.net Sun Dec 8 10:35:04 2019 From: for.mail at laposte.net (Sergi) Date: Sun, 8 Dec 2019 08:35:04 -0700 (MST) Subject: [Matplotlib-users] Recursive fonctions (fractal tree) Message-ID: <1575819304045-0.post@n5.nabble.com> Hi, I have to create a reccursive function with matplotlib in order to make a fractal tree. That's my fonction at this moment : import matplotlib.pyplot as plt from math import * def Drawn_(P,L,a,c,e): X = L*cos(a) + P[0] Y = L*sin(a) + P[1] M=[X,Y] plt.axis('equal') plt.plot([P[0],X],[P[1],Y],color=c,lw=e) return M def Tree(P,L,k,a,N,c): A=Drawn_(P,L,a+(pi/4),c,1) while N>>0: N=N-1 Arbre(A,L*k,k,0,N,'black') Arbre(A,L*k,k,(pi/2),N,'green') I had some pictures to show what are the problems. For the moment it don't work correctly because I can't create the tree with random angles and I don't know how to solve the problem and create the correct tree with recursivity.. Can someone help me please ? :) I have to restart the fonction or can we had, or change somethings to make it work ? -- Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html From tcaswell at gmail.com Mon Dec 9 12:26:15 2019 From: tcaswell at gmail.com (Thomas Caswell) Date: Mon, 9 Dec 2019 12:26:15 -0500 Subject: [Matplotlib-users] Matplotlib Research Software Engineering Fellow Message-ID: Hi folks, Matplotlib has received a grant from the Chan Zuckerberg Initiative to fund maintenance! As part of the grant, we have 1 year of funding for a Research Software Engineering Fellow to carry out this work. If you are interested in working on Matplotlib full time, please apply! See below for a link to the full job description and application instructions. The timeline on this is rather short, so applications are due Jan 3. https://discourse.matplotlib.org/t/now-hiring-matplotlib-research-software-engineering-fellow/20701 Tom and Hannah -- Thomas Caswell tcaswell at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: