From bala.biophysics at gmail.com Fri Jun 1 04:52:43 2018 From: bala.biophysics at gmail.com (Bala subramanian) Date: Fri, 1 Jun 2018 10:52:43 +0200 Subject: [Matplotlib-users] Creating a smooth surface in 3D In-Reply-To: References: Message-ID: Thanks for the inputs. After some efforts, I managed to create the surface by generating vertex and faces using an external program and mpl tools. ax1.plot_trisurf(x, y, z, triangles=faces,color='w', lw=10) ax1.scatter3D(x, y, z, c= cols,s=10) However, i am now trying to figure out the simple way to color the triangles using the vertex colors. For each vertex, I have assigned a color (ranges from blue to red) which in my case represents a calculated property. So basically I have a color array (cols in the above snippet) that I passed to the scatter function. I would like to know how I can color the triangle by interpolating to the colors of the vertex it belongs to. The available examples in net show the usage of colormaps. In my case, the triangles should adopt vertex colors. Any tricks to achieve this could be of much help. I have attached a sample figure, which i believe, could better elucidate the problem. On Mon, May 28, 2018 at 3:19 PM, Benjamin Root wrote: > mplot3d is good for real simple 3d scenes, but it falls apart when you > start composing things like this. You might want to consider using > something like glumpy or mayavi for better results. There are some > discussions in the past on the problems inherent in creating spheres in > mplot3d. There are some interesting solutions, but they get fairly complex > pretty quickly. > > Cheers! > Ben Root > > On Mon, May 28, 2018 at 8:16 AM, Bala subramanian < > bala.biophysics at gmail.com> wrote: > >> Dear mpl friends, >> >> My objective is to create a molecular surface using matplotlib. I used >> the snippet pasted below to create a series of spheres (attached png), >> drawn using the atom attributes (their positions and radius). From here, I >> would like to create a smooth surface which can depict the shape of the >> molecule surface (curves,cavities etc). Based on examples in net, I get a >> mixed feeling that either triangulation or making 3D grids are some >> directions to proceed. If anyone has some suggestions or better protocols >> for such task with some example data, it would be of great help to me. >> >> fig = plt.figure(figsize=(6,6),dpi=140) >> >> ax1 = fig.add_subplot(111, projection='3d') >> >> # Define spherical coordinates >> >> u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j] >> >> S = np.cos(u)*np.sin(v) >> >> C = np.sin(u)*np.sin(v) >> >> T = np.cos(v) >> >> for P,R in zip(positions,radii): >> >> ax1.plot_wireframe(R*S+P[0],R*C+P[1],R*T+P[2],color='r',alph >> a=0.4) >> >> Thanks in advance, >> >> Bala >> >> >> -- >> C. Balasubramanian >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> >> > -- C. Balasubramanian -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Surface.png Type: image/png Size: 290166 bytes Desc: not available URL: From bala.biophysics at gmail.com Sun Jun 3 06:40:56 2018 From: bala.biophysics at gmail.com (Bala subramanian) Date: Sun, 3 Jun 2018 12:40:56 +0200 Subject: [Matplotlib-users] clip a surface data Message-ID: Dear mpl friends, I have made a surface plot (attached) using trisurf. I want to remove from a part of the data from the view (encircled in the figure) so that the interior surface could be visible. Is there any facility available in mpl for the same. Just like making the front part invisible. I see functions like clip_path or clip_box etc, but from the documentation it is not clear for me to handle them. Any examples could be of much help. Thanks in advance, Bala -- C. Balasubramanian -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: clip.png Type: image/png Size: 595135 bytes Desc: not available URL: From bala.biophysics at gmail.com Sun Jun 3 06:45:32 2018 From: bala.biophysics at gmail.com (Bala subramanian) Date: Sun, 3 Jun 2018 12:45:32 +0200 Subject: [Matplotlib-users] Creating a smooth surface in 3D In-Reply-To: References: Message-ID: I managed to interpolate the face colors based on vertex property following the example given below. https://stackoverflow.com/questions/24218543/colouring-the-surface-of-a-sphere-with-a-set-of-scalar-values-in-matplotlib I am just updating here so as to direct anyone looking trying similar stuff. Thanks. On Fri, Jun 1, 2018 at 10:52 AM, Bala subramanian wrote: > Thanks for the inputs. After some efforts, I managed to create the surface > by generating vertex and faces using an external program and mpl tools. > > ax1.plot_trisurf(x, y, z, triangles=faces,color='w', lw=10) > > ax1.scatter3D(x, y, z, c= cols,s=10) > > However, i am now trying to figure out the simple way to color the > triangles using the vertex colors. > > For each vertex, I have assigned a color (ranges from blue to red) which > in my case represents a calculated property. So basically I have a color > array (cols in the above snippet) that I passed to the scatter function. I > would like to know how I can color the triangle by interpolating to the > colors of the vertex it belongs to. The available examples in net show the > usage of colormaps. In my case, the triangles should adopt vertex colors. > > Any tricks to achieve this could be of much help. I have attached a sample > figure, which i believe, could better elucidate the problem. > > > > > > > On Mon, May 28, 2018 at 3:19 PM, Benjamin Root > wrote: > >> mplot3d is good for real simple 3d scenes, but it falls apart when you >> start composing things like this. You might want to consider using >> something like glumpy or mayavi for better results. There are some >> discussions in the past on the problems inherent in creating spheres in >> mplot3d. There are some interesting solutions, but they get fairly complex >> pretty quickly. >> >> Cheers! >> Ben Root >> >> On Mon, May 28, 2018 at 8:16 AM, Bala subramanian < >> bala.biophysics at gmail.com> wrote: >> >>> Dear mpl friends, >>> >>> My objective is to create a molecular surface using matplotlib. I used >>> the snippet pasted below to create a series of spheres (attached png), >>> drawn using the atom attributes (their positions and radius). From here, I >>> would like to create a smooth surface which can depict the shape of the >>> molecule surface (curves,cavities etc). Based on examples in net, I get a >>> mixed feeling that either triangulation or making 3D grids are some >>> directions to proceed. If anyone has some suggestions or better protocols >>> for such task with some example data, it would be of great help to me. >>> >>> fig = plt.figure(figsize=(6,6),dpi=140) >>> >>> ax1 = fig.add_subplot(111, projection='3d') >>> >>> # Define spherical coordinates >>> >>> u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j] >>> >>> S = np.cos(u)*np.sin(v) >>> >>> C = np.sin(u)*np.sin(v) >>> >>> T = np.cos(v) >>> >>> for P,R in zip(positions,radii): >>> >>> ax1.plot_wireframe(R*S+P[0],R*C+P[1],R*T+P[2],color='r',alph >>> a=0.4) >>> >>> Thanks in advance, >>> >>> Bala >>> >>> >>> -- >>> C. Balasubramanian >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >>> >> > > > -- > C. Balasubramanian > -- C. Balasubramanian -------------- next part -------------- An HTML attachment was scrubbed... URL: From clemens.loschnauer at cantab.net Sun Jun 3 11:54:29 2018 From: clemens.loschnauer at cantab.net (clemens.loschnauer at cantab.net) Date: Sun, 3 Jun 2018 16:54:29 +0100 (BST) Subject: [Matplotlib-users] True 3D plotting with matplotlib Message-ID: <51692.5.151.22.24.1528041269.squirrel@www.cantab.net> Hi everyone, I have got a question with regards to the 3D plotting capabilites of matplotlib: Are there any plans/ongoing projects to make matplotlib (or its mplot3d submodule) suitable for complex 3D plotting? In particular, I am interested in plotting of geometric objects and surfaces and exporting these to vector graphics formats. I have done some research online and while there are some packages out there for 3D visualisation of data, all of them only export to raster graphics. The only program that I have come across that supports this is Mathematica, which is commercial. I believe that the option of producing publication-quality vector graphics for complex 3D scenes as might be desired in a scientific application is a feature that is currently missing in matplotlib. When I say high quality I have something like the 3D plots of the tikz/pgfplots packages in latex in mind, although again these do not support complex 3D scenes. I know there is mayavi, but I feel this does not offer the same quality for a scientific visualisation. Besides, it is a separate package and not part of matplotlib. An example of a visualisation that I want to achieve is the following: Plot a function of two variables as a 3D surface and then add a sphere that is tangent to the surface at some point. Then allow different camera angles with correct occlusion of hidden parts and varying levels of transparency. Add lighting and shading and export this as a vector graphic to a pdf file. Are there any plans to make something like this possible in matplotlib? If not, does anyone have hints as to what would be required to program this? From ben.v.root at gmail.com Sun Jun 3 12:26:40 2018 From: ben.v.root at gmail.com (Benjamin Root) Date: Sun, 3 Jun 2018 12:26:40 -0400 Subject: [Matplotlib-users] True 3D plotting with matplotlib In-Reply-To: <51692.5.151.22.24.1528041269.squirrel@www.cantab.net> References: <51692.5.151.22.24.1528041269.squirrel@www.cantab.net> Message-ID: Matplotlib has a layering rendering engine at the moment as its core design. This causes significant hurdles for a true 3D rendering engine within matplotlib. mplot3d is an attempt to work around that, but it is highly limited. The vispy project and glumpy are projects that we have encouraged development of in the past with the intent of integrating their technologies into matplotlib in the future in some future collaboration. While they have made significant strides, a roadmap for this integration has yet to materialize. On Sun, Jun 3, 2018 at 11:54 AM, wrote: > Hi everyone, > > I have got a question with regards to the 3D plotting capabilites of > matplotlib: Are there any plans/ongoing projects to make matplotlib (or > its mplot3d submodule) suitable for complex 3D plotting? > In particular, I am interested in plotting of geometric objects and > surfaces and exporting these to vector graphics formats. I have done some > research online and while there are some packages out there for 3D > visualisation of data, all of them only export to raster graphics. > The only program that I have come across that supports this is > Mathematica, which is commercial. I believe that the option of producing > publication-quality vector graphics for complex 3D scenes as might be > desired in a scientific application is a feature that is currently missing > in matplotlib. > When I say high quality I have something like the 3D plots of the > tikz/pgfplots packages in latex in mind, although again these do not > support complex 3D scenes. I know there is mayavi, but I feel this does > not offer the same quality for a scientific visualisation. Besides, it is > a separate package and not part of matplotlib. > An example of a visualisation that I want to achieve is the following: > Plot a function of two variables as a 3D surface and then add a sphere > that is tangent to the surface at some point. Then allow different camera > angles with correct occlusion of hidden parts and varying levels of > transparency. Add lighting and shading and export this as a vector graphic > to a pdf file. > > Are there any plans to make something like this possible in matplotlib? If > not, does anyone have hints as to what would be required to program this? > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Mon Jun 4 19:19:09 2018 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Tue, 05 Jun 2018 09:19:09 +1000 Subject: [Matplotlib-users] HiLo colormap Message-ID: <1528154349.385230.1396378984.5AB62F0F@webmail.messagingengine.com> Hi, Would a PR to add HiLo to Matplotlib be welcome? It seems very useful in general and especially in scientific data analysis, see e.g. https://postacquisition.wordpress.com/2015/08/25/go-west-ern/ See also this StackOverflow question: https://stackoverflow.com/questions/44116995/how-to-achieve-the-fiji-hilo-colormap-in-matplotlib-image-plots-to-mark-under Juan. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Jun 4 20:37:08 2018 From: tcaswell at gmail.com (Thomas Caswell) Date: Mon, 4 Jun 2018 19:37:08 -0500 Subject: [Matplotlib-users] HiLo colormap In-Reply-To: <1528154349.385230.1396378984.5AB62F0F@webmail.messagingengine.com> References: <1528154349.385230.1396378984.5AB62F0F@webmail.messagingengine.com> Message-ID: Given that you can already do that with the over/under values I suspect we just need better documentation of this feature. Extending the colormappable family of things to take over/under/bad colors as input might also be a nice convince to add. Tom On Mon, Jun 4, 2018 at 6:19 PM Juan Nunez-Iglesias wrote: > Hi, > > Would a PR to add HiLo to Matplotlib be welcome? It seems very useful in > general and especially in scientific data analysis, see e.g. > https://postacquisition.wordpress.com/2015/08/25/go-west-ern/ > > See also this StackOverflow question: > > https://stackoverflow.com/questions/44116995/how-to-achieve-the-fiji-hilo-colormap-in-matplotlib-image-plots-to-mark-under > > Juan. > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Mon Jun 4 21:18:59 2018 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Tue, 05 Jun 2018 11:18:59 +1000 Subject: [Matplotlib-users] HiLo colormap In-Reply-To: References: <1528154349.385230.1396378984.5AB62F0F@webmail.messagingengine.com> Message-ID: <1528161539.412799.1396469128.7EE5DBF9@webmail.messagingengine.com> On Tue, Jun 5, 2018, at 10:37 AM, Thomas Caswell wrote: > Given that you can already do that with the over/under values I > suspect we just need better documentation of this feature. I would argue that over/under is hacky for this use-case, given that the vmin and vmax have to be set not to the data but to something slightly less than the data. For int as in the SO answer, it was relatively straightforward. For float data now you have to set it to 0+epsilon, 1- epsilon, which isn't fun. > Extending the colormappable family of things to take over/under/bad > colors as input might also be a nice convince to add. Can you elaborate on the interface you are envisioning for this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Mon Jun 4 21:53:30 2018 From: tcaswell at gmail.com (Thomas Caswell) Date: Mon, 4 Jun 2018 20:53:30 -0500 Subject: [Matplotlib-users] HiLo colormap In-Reply-To: <1528161539.412799.1396469128.7EE5DBF9@webmail.messagingengine.com> References: <1528154349.385230.1396378984.5AB62F0F@webmail.messagingengine.com> <1528161539.412799.1396469128.7EE5DBF9@webmail.messagingengine.com> Message-ID: I would not call it hacky, this is exactly what the over/under functionality is for! It also fits the use-case of the blog post where there is some knowledge that 0 and the max-int are invalid. You are going to have a related issue with the color map. It is going to take the top/bottom 1/Nth of the range to be marked as over/under which may be _more_ that you want to grab. I also think it will grab asymmetrical ranges for log scales. For the API I am thinking something like `im = ax.imshow(..., over_color='r', under_color='b')` so that you can control that aspect of the color map from the user API. Tom On Mon, Jun 4, 2018 at 8:19 PM Juan Nunez-Iglesias wrote: > On Tue, Jun 5, 2018, at 10:37 AM, Thomas Caswell wrote: > > Given that you can already do that with the over/under values I suspect we > just need better documentation of this feature. > > > I would argue that over/under is hacky for this use-case, given that the > vmin and vmax have to be set not to the data but to something slightly less > than the data. For int as in the SO answer, it was relatively > straightforward. For float data now you have to set it to 0+epsilon, > 1-epsilon, which isn't fun. > > Extending the colormappable family of things to take over/under/bad colors > as input might also be a nice convince to add. > > > Can you elaborate on the interface you are envisioning for this? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jni.soma at gmail.com Mon Jun 4 21:58:00 2018 From: jni.soma at gmail.com (Juan Nunez-Iglesias) Date: Tue, 05 Jun 2018 11:58:00 +1000 Subject: [Matplotlib-users] HiLo colormap In-Reply-To: References: <1528154349.385230.1396378984.5AB62F0F@webmail.messagingengine.com> <1528161539.412799.1396469128.7EE5DBF9@webmail.messagingengine.com> Message-ID: <1528163880.421683.1396499288.6B6ABF73@webmail.messagingengine.com> On Tue, Jun 5, 2018, at 11:53 AM, Thomas Caswell wrote: > You are going to have a related issue with the color map. It is > going to take the top/bottom 1/Nth of the range to be marked as > over/under which may be _more_ that you want to grab. I also think it > will grab asymmetrical ranges for log scales. Ah. Yes this is totally terrible. Very good point. =) So colormaps are segmented to e.g. 256 by default, rather than all the input values? > For the API I am thinking something like > > `im = ax.imshow(..., over_color='r', under_color='b')` > > so that you can control that aspect of the color map from the > user API. That's not too bad I guess. =) So, to rephrase your position: a PR to the examples gallery would be welcome? =P -------------- next part -------------- An HTML attachment was scrubbed... URL: From aishwaryaselvaraj1708 at gmail.com Tue Jun 5 01:30:11 2018 From: aishwaryaselvaraj1708 at gmail.com (aishwarya selvaraj) Date: Tue, 5 Jun 2018 11:00:11 +0530 Subject: [Matplotlib-users] How to improve the speed of display implemented using matplotlib Message-ID: Hi all, I have 2 files created, one a .pyx file with a class named AndorCamersSDK which has a function named LiveAcquisition(). The second file, a .py file with a Class AndorCameraGUI which makes use of Tkinter to create a GUI. This class has function LivePlot(), and RepeatPlot().Inside LiveAcquisition() I am acquiring N number of frames and after acquiring each frame I need to display it using LivePlot() and RepeatPlot(). Without the display, just acquiring and storing for 300 frames takes 6.2 for execution, which is fine by me. But When I start displaying even for 100 frames it takes 54sec. I need to acquire and display within 6 sec for 300 frames. How do I solve this? ? File 1: .pyx code ; Present inside class AndorCameraSDK def LiveAcquisition(self): for i in range(no_of_frames): data[i,:,:] = PyArray_NewFromDescr( np.ndarray, np.dtype(' From efiring at hawaii.edu Tue Jun 5 02:04:47 2018 From: efiring at hawaii.edu (Eric Firing) Date: Mon, 4 Jun 2018 20:04:47 -1000 Subject: [Matplotlib-users] How to improve the speed of display implemented using matplotlib In-Reply-To: References: Message-ID: <471d6c1b-c827-420d-1d9a-2f0e7cd8c888@hawaii.edu> I think that at least part of the problem is that in RepeatPlot you are piling one image plot on top of another. Instead, keep a reference to the image object (let's call it "im") returned from your first call to imshow, in LivePlot, and then, in RepeatPlot, instead of calling imshow again, just call "self.im.set_data(image)". Eric On 2018/06/04 7:30 PM, aishwarya selvaraj wrote: > Hi all, > I have 2 files created, one a .pyx file with a class named > AndorCamersSDK which has a function named LiveAcquisition(). The second > file, a .py file with a Class AndorCameraGUI which makes use of Tkinter > to create a GUI. This class has function LivePlot(), and > RepeatPlot().Inside LiveAcquisition() I am acquiring N number of frames > and after acquiring each frame I need to display it using LivePlot() and > RepeatPlot(). Without the display, just acquiring and storing for 300 > frames takes 6.2 for execution, which is fine by me. But When I start > displaying even for 100 frames it takes 54sec. I need to acquire and > display within 6 sec for 300 frames. How do I solve this? > > ? > > File 1: .pyx code ; Present inside class AndorCameraSDK > > |defLiveAcquisition(self):fori > inrange(no_of_frames):data[i,:,:]=PyArray_NewFromDescr(np.ndarray,np.dtype(' ==65)or(i ==96):self.master.RepeatPlot(data[i,:,:])else:pass| > > ? > > File 2 : .py code; Below functions are present inside a class named > AndorCameraGUI > > |defLivePlot(self,image):self.count =0self.fig =Figure(figsize > =(4,5))self.fig.patch.set_facecolor('xkcd:light grey')# When this is > removed a white color is seen in the background of the figureself.a > =self.fig.add_subplot(111)self.a.set_xlim([0,self.image_width/int(self.HBin)])self.a.set_ylim([0,self.image_height/int(self.VBin)])image > =image.transpose()self.a.imshow(image,'gray')self.canvas > =FigureCanvasTkAgg(self.fig,self.master)self.canvas.draw()self.canvas.get_tk_widget().pack(side > =LEFT)self.toolbar > =NavigationToolbar2TkAgg(self.canvas,self.master)self.toolbar.update()self.canvas._tkcanvas.pack(side > =LEFT)#change this to TOP so thee the navigation toolbar on the left > down defRepeatPlot(self,image):image > =image.transpose()self.a.imshow(image,'gray')self.canvas.draw()| > > > -- > Regards, > Aishwarya Selvaraj > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From kellyw at uoregon.edu Tue Jun 5 12:45:57 2018 From: kellyw at uoregon.edu (Kelly Wilson) Date: Tue, 5 Jun 2018 09:45:57 -0700 Subject: [Matplotlib-users] How to improve the speed of display implemented using matplotlib In-Reply-To: <471d6c1b-c827-420d-1d9a-2f0e7cd8c888@hawaii.edu> References: <471d6c1b-c827-420d-1d9a-2f0e7cd8c888@hawaii.edu> Message-ID: <016901d3fcec$adb49210$091db630$@uoregon.edu> I agree with Eric about only creating one image and updating the data for that one image. I've also worked with Andor cameras and data acquisition. I did a few things to speed up the visualization and data collection. 1) I saved every frame, but I didn't change the image displayed for every picture I took. 2) I parallelized my code using the multiprocessing module with shared arrays and set the display to only pull data from the shared array when it was ready to display the next frame. If you do that and find that it still is going slower than you would like for displaying the data, you can course grain your display. For example, instead of having a 100 x 100 image from your 100 x 100 array, you could display a 50 x 50 image taking every other pixel from your array (e.g. self.im.set_data(data[i,::2,::2]). Kelly -----Original Message----- From: Matplotlib-users On Behalf Of Eric Firing Sent: Monday, June 4, 2018 11:05 PM To: matplotlib-users at python.org Subject: Re: [Matplotlib-users] How to improve the speed of display implemented using matplotlib I think that at least part of the problem is that in RepeatPlot you are piling one image plot on top of another. Instead, keep a reference to the image object (let's call it "im") returned from your first call to imshow, in LivePlot, and then, in RepeatPlot, instead of calling imshow again, just call "self.im.set_data(image)". Eric On 2018/06/04 7:30 PM, aishwarya selvaraj wrote: > Hi all, > I have 2 files created, one a .pyx file with a class named > AndorCamersSDK which has a function named LiveAcquisition(). The > second file, a .py file with a Class AndorCameraGUI which makes use of > Tkinter to create a GUI. This class has function LivePlot(), and > RepeatPlot().Inside LiveAcquisition() I am acquiring N number of > frames and after acquiring each frame I need to display it using > LivePlot() and RepeatPlot(). Without the display, just acquiring and > storing for 300 frames takes 6.2 for execution, which is fine by me. > But When I start displaying even for 100 frames it takes 54sec. I need > to acquire and display within 6 sec for 300 frames. How do I solve this? > > ? > > File 1: .pyx code ; Present inside class AndorCameraSDK > > |defLiveAcquisition(self):fori > inrange(no_of_frames):data[i,:,:]=PyArray_NewFromDescr( > np.ndarray,np.dtype(' )if(i==0):self.master.LivePlot(data[i,:,:])elif(i==2)or(i==15)or(i > ==65)or(i ==96):self.master.RepeatPlot(data[i,:,:])else:pass| > > ? > > File 2 : .py code; Below functions are present inside a class named > AndorCameraGUI > > |defLivePlot(self,image):self.count =0self.fig =Figure(figsize > =(4,5))self.fig.patch.set_facecolor('xkcd:light grey')# When this is > removed a white color is seen in the background of the figureself.a > =self.fig.add_subplot(111)self.a.set_xlim([0,self.image_width/int(self > .HBin)])self.a.set_ylim([0,self.image_height/int(self.VBin)])image > =image.transpose()self.a.imshow(image,'gray')self.canvas > =FigureCanvasTkAgg(self.fig,self.master)self.canvas.draw()self.canvas. > get_tk_widget().pack(side > =LEFT)self.toolbar > =NavigationToolbar2TkAgg(self.canvas,self.master)self.toolbar.update() > self.canvas._tkcanvas.pack(side =LEFT)#change this to TOP so thee the > navigation toolbar on the left down defRepeatPlot(self,image):image > =image.transpose()self.a.imshow(image,'gray')self.canvas.draw()| > > > -- > Regards, > Aishwarya Selvaraj > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > _______________________________________________ Matplotlib-users mailing list Matplotlib-users at python.org https://mail.python.org/mailman/listinfo/matplotlib-users From ludwig.schwardt at gmail.com Wed Jun 6 10:45:53 2018 From: ludwig.schwardt at gmail.com (Ludwig Schwardt) Date: Wed, 6 Jun 2018 16:45:53 +0200 Subject: [Matplotlib-users] True 3D plotting with matplotlib Message-ID: Hi, On the topic of publication-quality 3D vector graphics (but unfortunately not matplotlib...): I like Sketch. Although a bit old by now, you can still get it from sketch4latex.sourceforge.net. It has a bit of a learning curve (similar to TikZ) but is nice for basic 3D plots. I even used it to make a very basic vector animation viewable with Adobe Acrobat Reader (see slide 16 of the presentation at http://www.atnf.csiro.au/people/ban115/conferences/CALIM2014/talks/day3/calim2014_schwardt.pdf - will send source if interested). Good luck, Ludwig -------------- next part -------------- An HTML attachment was scrubbed... URL: From mbatr27 at gmail.com Thu Jun 7 09:31:03 2018 From: mbatr27 at gmail.com (Matthew Bradley) Date: Thu, 7 Jun 2018 07:31:03 -0600 Subject: [Matplotlib-users] First Time asking a question Message-ID: Hi all, This is my first time asking a question on this channel so everyone's help is appreciated. I'm trying to recreate a figure that my research lab first created in mathematica (attached in the email). I've tried to recreate the figure and plot area using the gridspec feature, and it's come close (my closest attempt is also attached). There are still a few things that need tweaking like making the lower right plot a square shape, decreasing the spacing between it and the plot to the left and above it. Here's my code as a starting point if you wanted to use it. The figure size doesn't have to be 25:20. fig = plt.figure(figsize=(25,20)) gs1 = gridspec.GridSpec(7,10) ax1 = plt.subplot(gs1[1:,0]) ax2 = plt.subplot(gs1[0:6,1]) ax3 = plt.subplot(gs1[1:,3]) ax4 = plt.subplot(gs1[0:6,4]) ax5 = plt.subplot(gs1[1,6]) ax6 = plt.subplot(gs1[0,7]) ax7 = plt.subplot(gs1[0,9]) ax8 = plt.subplot(gs1[4:,6:]) gs1.update(wspace=0.02,hspace=0) My question is how to do this most efficiently using gridspec or if there is another feature that makes such a setup a much easier task. I think I can add more columns and rows to the gridspec and custom define row height and column width ratios to recreate the plot but that seems like it would take a lot of trial and error on my part. Likewise if I were to define multiple gridspecs and define their layouts with the gridspec.update command would take some guessing and checking. A gridspec within a gridspec using GridSpecFromSubPlot command might be able to work but it doesn't have an attribute .update() to customize the wspace between plots in the gridspec that I know of. Is there a way to define a plots origin (in pixel or some other coordinates) and its extent? ?Thanks in advance!? -- Matthew Bradley -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: example.PNG Type: image/png Size: 4174129 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: download (1).png Type: image/png Size: 23532 bytes Desc: not available URL: From efiring at hawaii.edu Thu Jun 7 21:45:48 2018 From: efiring at hawaii.edu (Eric Firing) Date: Thu, 7 Jun 2018 15:45:48 -1000 Subject: [Matplotlib-users] First Time asking a question In-Reply-To: References: Message-ID: Matthew, If you want to manually specify the position of each Axes rectangle in inches--so you can explicitly lay out the figure exactly as you want-- you can do it by creating each Axes with a helper like this: def axes_inches(fig, rect, **kw): """ Wrapper for Figure.add_axes in which *rect* is given in inches. The translation to normalized coordinates is done immediately based on the present figsize. *rect* is left, bottom, width, height in inches *kw* are passed to Figure.add_axes """ fw = fig.get_figwidth() fh = fig.get_figheight() l, b, w, h = rect relrect = [l / fw, b / fh, w / fw, h / fh] ax = fig.add_axes(relrect, **kw) return ax This only works if you are not using an interactive backend, or if you are using an interactive backend and you specify a dpi small enough so that your specified figure size fits on your screen with room for boundaries and the toolbar. If it doesn't, unfortunately, it will be resized to fit, and then it won't scale properly when you save the figure to a file. For example, if you are displaying on the screen with a backend like qt5agg and you want the figure size to be (25, 21) when you write it (e.g., to a pdf file), then you will probably need to create the figure with dpi=20 or something like that. When you save to a file, you can of course do so with a different dpi. Eric On 2018/06/07 3:31 AM, Matthew Bradley wrote: > Hi all, > > This is my first time asking a question on this channel so everyone's > help is appreciated. I'm trying to recreate a figure that my research > lab first created in mathematica (attached in the email). I've tried to > recreate the figure and plot area using the gridspec feature, and it's > come close (my closest attempt is also attached). There are still a few > things that need tweaking like making the lower right plot a square > shape, decreasing the spacing between it and the plot to the left and > above it. > > Here's my code as a starting point if you wanted to use it. The figure > size doesn't have to be 25:20. > > fig = plt.figure(figsize=(25,20)) > gs1 = gridspec.GridSpec(7,10) > > ax1 = plt.subplot(gs1[1:,0]) > ax2 = plt.subplot(gs1[0:6,1]) > ax3 = plt.subplot(gs1[1:,3]) > ax4 = plt.subplot(gs1[0:6,4]) > ax5 = plt.subplot(gs1[1,6]) > ax6 = plt.subplot(gs1[0,7]) > ax7 = plt.subplot(gs1[0,9]) > ax8 = plt.subplot(gs1[4:,6:]) > gs1.update(wspace=0.02,hspace=0) > > > My question is how to do this most efficiently using gridspec or if > there is another feature that makes such a setup a much easier task. I > think I can add more columns and rows to the gridspec and custom define > row height and column width ratios to recreate the plot but that seems > like it would take a lot of trial and error on my part. Likewise if I > were to define multiple gridspecs and define their layouts with the > gridspec.update command would take some guessing and checking. A > gridspec within a gridspec using GridSpecFromSubPlot command might be > able to work but it doesn't have an attribute .update() to customize the > wspace between plots in the gridspec that I know of. Is there a way to > define a plots origin (in pixel or some other coordinates) and its extent? > > ?Thanks in advance!? > > > -- > Matthew Bradley > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > From ndbecker2 at gmail.com Fri Jun 8 08:01:51 2018 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 8 Jun 2018 08:01:51 -0400 Subject: [Matplotlib-users] Bizarre clipping of title when markers used Message-ID: I haven't been able to reproduce yet in a minimal example, but in this code, if markers are used in the plot, then the title is clipped off and not shown. If the markers= is commented out, then the title is fine. I know it's clipped, because if I specify set_title ('blah', y=0.5) < set y to something < .95 Then the title is displayed (but in the wrong position). So, if markers are present, title is clipped off. No markers, title is fine. My code is here (you can't run it I'm afraid): matplotlib=2.2.2 import pandas as pd def do_plot(other_csv, mine_xlsx, name): df_tdla_96 = pd.read_csv (other_csv) df_tdla_96_mine = pd.read_excel (mine_xlsx) df_tdla_96_mine = df_tdla_96_mine[['esno_corrected', 'per']] df_tdla_96_mine.rename (index=str, columns={'esno_corrected' : 'SNR', 'per' : 'Hughes'}, inplace=True) df_tdla_96.drop(labels='Hughes', inplace=True, axis=1) df_tdla_96_merge = pd.merge(left=df_tdla_96, right=df_tdla_96_mine, on='SNR') from matplotlib.lines import Line2D from itertools import cycle m_cycle = cycle(Line2D.filled_markers) import matplotlib.pyplot as plt fig, ax = plt.subplots()#, sharex=True) for company in df_tdla_96_merge.columns[1:]: df = df_tdla_96_merge[['SNR', company]] ax.semilogy(df['SNR'], df[company], marker='x') ax.set_title('Simple plot') #ax.set_title('blah', fontsize=12, y=0.95) # ax.set_xlabel('SNR') # ax.set_ylabel('BLER') # ax.legend(loc='best') #fig.suptitle('blah', fontsize=12, x=0.5, y=0.9) ax.grid() #plt.tight_layout() plt.show() #plt.tight_layout() #plt.savefig('tdla_96.pdf') do_plot('tdla_96_other.csv', 'tdla_96_mrc_wiener.xlsx', 'TDLA 96 CP-OFDM') -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Fri Jun 8 09:17:58 2018 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 08 Jun 2018 09:17:58 -0400 Subject: [Matplotlib-users] Bizarre clipping of title when markers used References: Message-ID: Neal Becker wrote: > I haven't been able to reproduce yet in a minimal example, but in this > code, if markers are used in the plot, then the title is clipped off and > not shown. If the markers= is commented out, then the title is fine. I > know it's clipped, because if I specify > set_title ('blah', y=0.5) < set y to something < .95 > Then the title is displayed (but in the wrong position). > > So, if markers are present, title is clipped off. No markers, title is > fine. > > My code is here (you can't run it I'm afraid): > > matplotlib=2.2.2 > > import pandas as pd > > def do_plot(other_csv, mine_xlsx, name): > df_tdla_96 = pd.read_csv (other_csv) > df_tdla_96_mine = pd.read_excel (mine_xlsx) > df_tdla_96_mine = df_tdla_96_mine[['esno_corrected', 'per']] > df_tdla_96_mine.rename (index=str, columns={'esno_corrected' : 'SNR', > 'per' : 'Hughes'}, inplace=True) > df_tdla_96.drop(labels='Hughes', inplace=True, axis=1) > df_tdla_96_merge = pd.merge(left=df_tdla_96, right=df_tdla_96_mine, > on='SNR') > from matplotlib.lines import Line2D > from itertools import cycle > m_cycle = cycle(Line2D.filled_markers) > import matplotlib.pyplot as plt > fig, ax = plt.subplots()#, sharex=True) > for company in df_tdla_96_merge.columns[1:]: > df = df_tdla_96_merge[['SNR', company]] > ax.semilogy(df['SNR'], df[company], marker='x') > ax.set_title('Simple plot') > #ax.set_title('blah', fontsize=12, y=0.95) > # ax.set_xlabel('SNR') > # ax.set_ylabel('BLER') > # ax.legend(loc='best') > #fig.suptitle('blah', fontsize=12, x=0.5, y=0.9) > ax.grid() > #plt.tight_layout() > plt.show() > > #plt.tight_layout() > #plt.savefig('tdla_96.pdf') > > do_plot('tdla_96_other.csv', 'tdla_96_mrc_wiener.xlsx', 'TDLA 96 CP-OFDM') It appears adding ax.set(clip_on=False) fixes it, but this bug seems very strange. From tcaswell at gmail.com Sun Jun 10 11:21:04 2018 From: tcaswell at gmail.com (Thomas Caswell) Date: Sun, 10 Jun 2018 10:21:04 -0500 Subject: [Matplotlib-users] Bizarre clipping of title when markers used In-Reply-To: References: Message-ID: Neal, Can you reproduce this with random data? From which side is the text clipped? Tom On Fri, Jun 8, 2018 at 8:18 AM Neal Becker wrote: > Neal Becker wrote: > > > I haven't been able to reproduce yet in a minimal example, but in this > > code, if markers are used in the plot, then the title is clipped off and > > not shown. If the markers= is commented out, then the title is fine. I > > know it's clipped, because if I specify > > set_title ('blah', y=0.5) < set y to something < .95 > > Then the title is displayed (but in the wrong position). > > > > So, if markers are present, title is clipped off. No markers, title is > > fine. > > > > My code is here (you can't run it I'm afraid): > > > > matplotlib=2.2.2 > > > > import pandas as pd > > > > def do_plot(other_csv, mine_xlsx, name): > > df_tdla_96 = pd.read_csv (other_csv) > > df_tdla_96_mine = pd.read_excel (mine_xlsx) > > df_tdla_96_mine = df_tdla_96_mine[['esno_corrected', 'per']] > > df_tdla_96_mine.rename (index=str, columns={'esno_corrected' : 'SNR', > > 'per' : 'Hughes'}, inplace=True) > > df_tdla_96.drop(labels='Hughes', inplace=True, axis=1) > > df_tdla_96_merge = pd.merge(left=df_tdla_96, right=df_tdla_96_mine, > > on='SNR') > > from matplotlib.lines import Line2D > > from itertools import cycle > > m_cycle = cycle(Line2D.filled_markers) > > import matplotlib.pyplot as plt > > fig, ax = plt.subplots()#, sharex=True) > > for company in df_tdla_96_merge.columns[1:]: > > df = df_tdla_96_merge[['SNR', company]] > > ax.semilogy(df['SNR'], df[company], marker='x') > > ax.set_title('Simple plot') > > #ax.set_title('blah', fontsize=12, y=0.95) > > # ax.set_xlabel('SNR') > > # ax.set_ylabel('BLER') > > # ax.legend(loc='best') > > #fig.suptitle('blah', fontsize=12, x=0.5, y=0.9) > > ax.grid() > > #plt.tight_layout() > > plt.show() > > > > #plt.tight_layout() > > #plt.savefig('tdla_96.pdf') > > > > do_plot('tdla_96_other.csv', 'tdla_96_mrc_wiener.xlsx', 'TDLA 96 > CP-OFDM') > > It appears adding ax.set(clip_on=False) fixes it, but this bug seems very > strange. > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tcaswell at gmail.com Sun Jun 10 11:27:10 2018 From: tcaswell at gmail.com (Thomas Caswell) Date: Sun, 10 Jun 2018 10:27:10 -0500 Subject: [Matplotlib-users] HiLo colormap In-Reply-To: <1528163880.421683.1396499288.6B6ABF73@webmail.messagingengine.com> References: <1528154349.385230.1396378984.5AB62F0F@webmail.messagingengine.com> <1528161539.412799.1396469128.7EE5DBF9@webmail.messagingengine.com> <1528163880.421683.1396499288.6B6ABF73@webmail.messagingengine.com> Message-ID: > So colormaps are segmented to e.g. 256 by default, rather than all the input values? Yes, because colormap objects may be re-used with many data sets so can't know anything about the input values ahead of time (They don't even get to see the raw data as it has been through a Normalize object first). Yes, a PR with that example would be welcome. Tom On Mon, Jun 4, 2018 at 8:58 PM Juan Nunez-Iglesias wrote: > On Tue, Jun 5, 2018, at 11:53 AM, Thomas Caswell wrote: > > You are going to have a related issue with the color map. It is going to > take the top/bottom 1/Nth of the range to be marked as over/under which may > be _more_ that you want to grab. I also think it will grab asymmetrical > ranges for log scales. > > > Ah. Yes this is totally terrible. Very good point. =) So colormaps are > segmented to e.g. 256 by default, rather than all the input values? > > For the API I am thinking something like > > `im = ax.imshow(..., over_color='r', under_color='b')` > > so that you can control that aspect of the color map from the user API. > > > That's not too bad I guess. =) > > So, to rephrase your position: a PR to the examples gallery would be > welcome? =P > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincent.adrien at gmail.com Sun Jun 10 14:36:12 2018 From: vincent.adrien at gmail.com (vincent.adrien at gmail.com) Date: Sun, 10 Jun 2018 11:36:12 -0700 Subject: [Matplotlib-users] specify line plot color In-Reply-To: References: <5a560313-fa0c-9ee8-2d19-0eb0e00aab47@gmail.com> Message-ID: Hi alberto, If I have correctly understood your wish, you may be looking for in [numpy.savetxt](https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.savetxt.html) and [numpy.loadtxt](https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.loadtxt.html). This may not be really Matplotlib's field anymore, but please find attached a small example on how to record data into a flat text file and reload them. Hopefully this will helpful to you. Best regards, Adrien On 06/10/2018 08:30 AM, alberto wrote: > Hi, > I wrote days ago about script python > I would ask you if exist a way to print in a file the data of a plot > > this is my script > > > #!/usr/bin/env python > > > import numpy as np > import matplotlib.pyplot as plt > import sys > > #%% > # Temperature that we are interested in > target_T = 10.0 > #%% Load all condtens data > data = np.loadtxt("Pb8I28-MA-BISIMID_101010Kp_FR.condtens") > #%% Load trace data > data2 = np.loadtxt("Pb8I28-MA-BISIMID_101010Kp_FR.trace") > #print(data[:,1]) > #%% > # Select only the data points computed at that specific temperature > T = data[:, 1] > indices = (T == target_T) > #print(indices) > > #%%Fermi levels converted in electronvolts > Ef = 13.60 * data[indices, 0] > print(Ef) > > > #%% plot trace at T > Fermi_level = 4.44075 # (in eV) > > plt.figure() > labels = ("$\sigma$ / $tau$",) > for i, label in enumerate(labels): > ??? plt.plot((Ef - Fermi_level), data2[indices,(abs(5))], label=label) > plt.legend(loc="best") > plt.xlabel(r"Energy-Efermi [eV]") > plt.ylabel(r"$\sigma$/$\tau$ [$\Omega$ m s]") > plt.tight_layout() > plt.show() > > > #%% plot DOS(Ef) at T > > au_to_m = 5.291772083E-11 > V = 7670.7134 # a.u.^3 > m_el = 9.10938356E-31 #Kg > V_m3 = V*(au_to_m)**3 > print(V_m3) > > plt.figure() > labels = ("DOS",) > for i, label in enumerate(labels): > ??? plt.plot(Ef, data2[indices,(3)], label=label) > plt.legend(loc="best") > plt.xlabel(r"Ef [eV]") > plt.ylabel(r"n /($\mu)$ [e / m^3]") > plt.tight_layout() > plt.show() > > > #%% > # And recast as an array of 3x3 matrices for convenience > # Column numbers are easy to follow: 1 for Ef, 1 for T, 1 for N, 9 for > sigma, > # and then comes the Seebeck coefficient > sigma = data[indices, 3:12].reshape((-1, 3, 3)) > sys.stdout=open('prova.txt','wt') > print(sigma) > seebeck = data[indices, 12:21].reshape((-1, 3, 3)) > > # Plot the xx, yy and zz components as a function of the first column > plt.figure() > labels = ("xx", "yy", "zz") > for i, label in enumerate(labels): > ??? plt.plot(Ef, sigma[:, i, i], label=label) > plt.legend(loc="best") > plt.xlabel(r"Energy [eV]") > plt.ylabel(r"$\sigma$ [1/$\Omega$ m s]") > #plt.axis([4,8,-1,8]) > plt.tight_layout() > plt.show() > > > in particular I would write four columns with ef and xx yy zz in a > datafile.txt > > regards > > Alberto > > 2018-04-16 19:22 GMT+02:00 alberto >: > > Hi, > thank you so much for your help > > Alberto > > 2018-04-16 18:58 GMT+02:00 vincent.adrien at gmail.com > >: > > Hi Alberto, > > I now understand better. No need to flip you data then: you can > actually explicitly specify the color that? you want in the > `plot` function, with the *color* keyword argument. See the > attached script that should hopefully help you to get what you want. > > Best regards, > Adrien > > On 04/16/2018 09:20 AM, alberto wrote: > > Hi vincet, > > in my plot (see .png file) > > I would invert the color > > xx --> green > zz--> blue > > > > regards > > Alberto > > ? > Pb8I28-MA-PERF-BISIMID_32Kp_101010.condtens > > > ? > > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: example_alberto.py Type: text/x-python Size: 1726 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: for_alberto.pdf Type: application/pdf Size: 13434 bytes Desc: not available URL: -------------- next part -------------- # Data used to plot a figure # ef, xx, yy, zz 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00 1.111111e-01, 3.333333e-01, 1.111111e-01, 1.234568e-02 2.222222e-01, 4.714045e-01, 2.222222e-01, 4.938272e-02 3.333333e-01, 5.773503e-01, 3.333333e-01, 1.111111e-01 4.444444e-01, 6.666667e-01, 4.444444e-01, 1.975309e-01 5.555556e-01, 7.453560e-01, 5.555556e-01, 3.086420e-01 6.666667e-01, 8.164966e-01, 6.666667e-01, 4.444444e-01 7.777778e-01, 8.819171e-01, 7.777778e-01, 6.049383e-01 8.888889e-01, 9.428090e-01, 8.888889e-01, 7.901235e-01 1.000000e+00, 1.000000e+00, 1.000000e+00, 1.000000e+00 From ndbecker2 at gmail.com Tue Jun 12 09:34:28 2018 From: ndbecker2 at gmail.com (Neal Becker) Date: Tue, 12 Jun 2018 09:34:28 -0400 Subject: [Matplotlib-users] Bizarre clipping of title when markers used In-Reply-To: References: Message-ID: Sorry, got busy on other things. The title seems to be clipped by the top axis. Maybe I can make a screenshot. On Sun, Jun 10, 2018 at 11:21 AM Thomas Caswell wrote: > Neal, > > Can you reproduce this with random data? From which side is the text > clipped? > > Tom > > On Fri, Jun 8, 2018 at 8:18 AM Neal Becker wrote: > >> Neal Becker wrote: >> >> > I haven't been able to reproduce yet in a minimal example, but in this >> > code, if markers are used in the plot, then the title is clipped off and >> > not shown. If the markers= is commented out, then the title is fine. I >> > know it's clipped, because if I specify >> > set_title ('blah', y=0.5) < set y to something < .95 >> > Then the title is displayed (but in the wrong position). >> > >> > So, if markers are present, title is clipped off. No markers, title is >> > fine. >> > >> > My code is here (you can't run it I'm afraid): >> > >> > matplotlib=2.2.2 >> > >> > import pandas as pd >> > >> > def do_plot(other_csv, mine_xlsx, name): >> > df_tdla_96 = pd.read_csv (other_csv) >> > df_tdla_96_mine = pd.read_excel (mine_xlsx) >> > df_tdla_96_mine = df_tdla_96_mine[['esno_corrected', 'per']] >> > df_tdla_96_mine.rename (index=str, columns={'esno_corrected' : >> 'SNR', >> > 'per' : 'Hughes'}, inplace=True) >> > df_tdla_96.drop(labels='Hughes', inplace=True, axis=1) >> > df_tdla_96_merge = pd.merge(left=df_tdla_96, right=df_tdla_96_mine, >> > on='SNR') >> > from matplotlib.lines import Line2D >> > from itertools import cycle >> > m_cycle = cycle(Line2D.filled_markers) >> > import matplotlib.pyplot as plt >> > fig, ax = plt.subplots()#, sharex=True) >> > for company in df_tdla_96_merge.columns[1:]: >> > df = df_tdla_96_merge[['SNR', company]] >> > ax.semilogy(df['SNR'], df[company], marker='x') >> > ax.set_title('Simple plot') >> > #ax.set_title('blah', fontsize=12, y=0.95) >> > # ax.set_xlabel('SNR') >> > # ax.set_ylabel('BLER') >> > # ax.legend(loc='best') >> > #fig.suptitle('blah', fontsize=12, x=0.5, y=0.9) >> > ax.grid() >> > #plt.tight_layout() >> > plt.show() >> > >> > #plt.tight_layout() >> > #plt.savefig('tdla_96.pdf') >> > >> > do_plot('tdla_96_other.csv', 'tdla_96_mrc_wiener.xlsx', 'TDLA 96 >> CP-OFDM') >> >> It appears adding ax.set(clip_on=False) fixes it, but this bug seems very >> strange. >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users at python.org >> https://mail.python.org/mailman/listinfo/matplotlib-users >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Tue Jun 12 09:49:44 2018 From: ndbecker2 at gmail.com (Neal Becker) Date: Tue, 12 Jun 2018 09:49:44 -0400 Subject: [Matplotlib-users] Bizarre clipping of title when markers used In-Reply-To: References: Message-ID: Looks like I can't reproduce it now On Tue, Jun 12, 2018 at 9:34 AM Neal Becker wrote: > Sorry, got busy on other things. The title seems to be clipped by the top > axis. Maybe I can make a screenshot. > > On Sun, Jun 10, 2018 at 11:21 AM Thomas Caswell > wrote: > >> Neal, >> >> Can you reproduce this with random data? From which side is the text >> clipped? >> >> Tom >> >> On Fri, Jun 8, 2018 at 8:18 AM Neal Becker wrote: >> >>> Neal Becker wrote: >>> >>> > I haven't been able to reproduce yet in a minimal example, but in this >>> > code, if markers are used in the plot, then the title is clipped off >>> and >>> > not shown. If the markers= is commented out, then the title is fine. >>> I >>> > know it's clipped, because if I specify >>> > set_title ('blah', y=0.5) < set y to something < .95 >>> > Then the title is displayed (but in the wrong position). >>> > >>> > So, if markers are present, title is clipped off. No markers, title is >>> > fine. >>> > >>> > My code is here (you can't run it I'm afraid): >>> > >>> > matplotlib=2.2.2 >>> > >>> > import pandas as pd >>> > >>> > def do_plot(other_csv, mine_xlsx, name): >>> > df_tdla_96 = pd.read_csv (other_csv) >>> > df_tdla_96_mine = pd.read_excel (mine_xlsx) >>> > df_tdla_96_mine = df_tdla_96_mine[['esno_corrected', 'per']] >>> > df_tdla_96_mine.rename (index=str, columns={'esno_corrected' : >>> 'SNR', >>> > 'per' : 'Hughes'}, inplace=True) >>> > df_tdla_96.drop(labels='Hughes', inplace=True, axis=1) >>> > df_tdla_96_merge = pd.merge(left=df_tdla_96, right=df_tdla_96_mine, >>> > on='SNR') >>> > from matplotlib.lines import Line2D >>> > from itertools import cycle >>> > m_cycle = cycle(Line2D.filled_markers) >>> > import matplotlib.pyplot as plt >>> > fig, ax = plt.subplots()#, sharex=True) >>> > for company in df_tdla_96_merge.columns[1:]: >>> > df = df_tdla_96_merge[['SNR', company]] >>> > ax.semilogy(df['SNR'], df[company], marker='x') >>> > ax.set_title('Simple plot') >>> > #ax.set_title('blah', fontsize=12, y=0.95) >>> > # ax.set_xlabel('SNR') >>> > # ax.set_ylabel('BLER') >>> > # ax.legend(loc='best') >>> > #fig.suptitle('blah', fontsize=12, x=0.5, y=0.9) >>> > ax.grid() >>> > #plt.tight_layout() >>> > plt.show() >>> > >>> > #plt.tight_layout() >>> > #plt.savefig('tdla_96.pdf') >>> > >>> > do_plot('tdla_96_other.csv', 'tdla_96_mrc_wiener.xlsx', 'TDLA 96 >>> CP-OFDM') >>> >>> It appears adding ax.set(clip_on=False) fixes it, but this bug seems >>> very >>> strange. >>> >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users at python.org >>> https://mail.python.org/mailman/listinfo/matplotlib-users >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniele at grinta.net Fri Jun 29 20:30:57 2018 From: daniele at grinta.net (Daniele Nicolodi) Date: Fri, 29 Jun 2018 18:30:57 -0600 Subject: [Matplotlib-users] Formatting numbers in "nicer" scientific notation Message-ID: <97011cec-22bb-c467-847e-6861b13183e5@grinta.net> Hello all, sorry for the vague title, but I didn't know how else to formulate it. I'm looking for a facility to format numbers in a nicer way, namely to turno 3.14e-5 into something like $3.14 \times 10^{\minus 5}$. I'm almost sure I've seen something like that in matplotlib somewhere but I'm not able to find it anymore. Is my recollection wrong? Does anyone know if that is implemented by some other library? Thank you. Cheers, Dan From vincent.adrien at gmail.com Fri Jun 29 21:31:09 2018 From: vincent.adrien at gmail.com (vincent.adrien at gmail.com) Date: Fri, 29 Jun 2018 18:31:09 -0700 Subject: [Matplotlib-users] Formatting numbers in "nicer" scientific notation In-Reply-To: <97011cec-22bb-c467-847e-6861b13183e5@grinta.net> References: <97011cec-22bb-c467-847e-6861b13183e5@grinta.net> Message-ID: <85406e05-889f-0e15-e3e3-cc816399fd37@gmail.com> Hi Daniele, You might be looking for the `MathText`-capability of (some of the?) Matplotlib formatters. See for example: - https://matplotlib.org/gallery/ticks_and_spines/scalarformatter.html - https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.ticklabel_format.html Please find attached a small example on how MathText may help to get where you want (if I have understood your goal correctly). Another more advanced fashion may be to write your own formatter with something like `FuncFormatter` (https://matplotlib.org/api/ticker_api.html#matplotlib.ticker.FuncFormatter) but that would definitively be more work... Hopefully this helps. Best regards, Adrien On 06/29/2018 05:30 PM, Daniele Nicolodi wrote: > Hello all, > > sorry for the vague title, but I didn't know how else to formulate it. > I'm looking for a facility to format numbers in a nicer way, namely to > turno 3.14e-5 into something like $3.14 \times 10^{\minus 5}$. > > I'm almost sure I've seen something like that in matplotlib somewhere > but I'm not able to find it anymore. Is my recollection wrong? Does > anyone know if that is implemented by some other library? > > Thank you. Cheers, > Dan > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users at python.org > https://mail.python.org/mailman/listinfo/matplotlib-users > -------------- next part -------------- A non-text attachment was scrubbed... Name: example_mathtext.py Type: text/x-python Size: 628 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: mathtext_ticker.png Type: image/png Size: 16594 bytes Desc: not available URL: