[Matplotlib-users] cannot display label on my axes
Hello, It's my first post on this forum and I'm very happy to discover a forum dedicated to matplotlib. I 've begun recently a development with matplotlib inside my python (2.7)application. In a first step I've developped a stand alone graphical display and it runs properly. In a second step, I try to manage this graphical display through gtk (because my main application is in python/gtk) : now, most of functionalities run well, but labels on my 3 axes are no more displayed and I don't understand why. Thank you for all suggestions. Here is the source code with gtk - import sys import gtk import numpy as np import matplotlib.pyplot as plt from matplotlib.figure import Figure from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar from StringIO import StringIO # StringIO behaves like a file object from mpl_toolkits.mplot3d import Axes3D from matplotlib.colors import colorConverter from matplotlib.widgets import Button class SectorDisplay2__: """ Display view of sectors and volumes """ def __init__(self): win = gtk.Window() win.connect("destroy",self.SectorDisplayClosePanel) win.set_default_size(800,800) vbox = gtk.VBox() win.add(vbox) fig = Figure() canvas = FigureCanvas(fig) # a gtk.DrawingArea ax = Axes3D(fig) #get lines as csv description line = "" line = line+"VOL1;P4120;0;999;-49.687222;-1.521667;\n" line = line+"VOL1;P4121;0;999;-49.687222;-2.207222;\n" line = line+"VOL1;P1421;0;999;-49.237500;-2.207222;\n" line = line+"VOL1;P1422;0;999;-49.237500;-1.521667;\n" line = line+"VOL1;P4120;0;999;-49.687222;-1.521667;\n" lines = StringIO(line) # get the list of point coordinates and level data = np.loadtxt(lines, delimiter=';', usecols = (0,1,2,3,4,5), # 0=volume 1=point 2=lower level 3=upper_level, 4=lat 5=long dtype = np.dtype({'names':['volume','point','lower','upper','lat','long'], 'formats': ['S20','S5','i4','i4','f4','f4']}) ) # Get one particular volume onevolume = data[data['volume']=="VOL1"] ax.plot(onevolume['long'],onevolume['lat'],onevolume['upper']) ax.plot(onevolume['long'],onevolume['lat'],onevolume['lower']) for i in range(len(onevolume)-1): ax.plot([onevolume['long'][i],onevolume['long'][i]], [onevolume['lat'][i],onevolume['lat'][i]], [onevolume['lower'][i],onevolume['upper'][i]]) ax.set_ylabel('Latitude (deg)') ax.set_xlabel('Longitude (deg)') ax.set_zlabel('Level (100xfeet)') ax.set_title('Volumic definition') vbox.pack_start(canvas) toolbar = NavigationToolbar(canvas,win) vbox.pack_start(toolbar,False,False) win.show_all() # Run the Gtk mainloop gtk.main() def SectorDisplayClosePanel(self,caller): gtk.main_quit() if __name__ == '__main__': SectorDisplay2__() - Here is the initial source code without gtk: - import sys import numpy as np import matplotlib.pyplot as plt from matplotlib.figure import Figure from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar from StringIO import StringIO # StringIO behaves like a file object from mpl_toolkits.mplot3d import Axes3D from matplotlib.colors import colorConverter from matplotlib.widgets import Button class SectorDisplay2__: """ Display view of sectors and volumes """ def __init__(self): """ @param parentWin: Window which is parent of this window @type parentWin: Widget @param typevol: give the type of volume : volume, sector, non controlled area ... @type typevol: str
[Matplotlib-users] unable to draw text at angles other than 0 or 90
Hello, Concernig the source code of my previous post, the use of "ax.set_title('Volumic definition')" generate the following message: /opt/IPASTEST/lib/python2.7/site-packages/matplotlib/backends/backend_gdk.py:150: UserWarning: backend_gdk: unable to draw text at angles other than 0 or 90 'other than 0 or 90') I thought that by default the drawing requested by my instruction set_title is 0 Thank you for your suggestions -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] RE : unable to draw text at angles other than 0 or 90
Hi Ben, I don't want to display rotate text ! I just need to display a simple text to my figure : ax.text(onevolume['long'][i],onevolume['lat'][i],onevolume['upper'][i],onevolume['point'][i],color=linecolor) In addition, I do not understand your remark about GDK, If I remember, I need to use the following modules because FigureCanvas and NavigationToolbar are required. from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar Anyway I cannot reproduce the warning, it is a little bit strange ! Thank you De : ben.v.r...@gmail.com [ben.v.r...@gmail.com] de la part de Benjamin Root [ben.r...@ou.edu] Date d'envoi : jeudi 11 août 2011 16:05 À : WALTER Alain Cc : matplotlib-users@lists.sourceforge.net Objet : Re: [Matplotlib-users] unable to draw text at angles other than 0 or 90 On Thursday, August 11, 2011, WALTER Alain mailto:alain.wal...@thalesgroup.com>> wrote: > Hello, > Concernig the source code of my previous post, the use of > "ax.set_title('Volumic definition')" generate the following message: > /opt/IPASTEST/lib/python2.7/site-packages/matplotlib/backends/backend_gdk.py:150: > UserWarning: backend_gdk: unable to draw text at angles other than 0 or 90 > 'other than 0 or 90') > I thought that by default the drawing requested by my instruction set_title > is 0 > Thank you for your suggestions Alain, Only the AGG-based backends can display rotated text. Is there a particular reason why you are using GDK backend? Since you are doing Gtk programming, I would recommend using GTKAgg. Ben Root -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] RE : RE : unable to draw text at angles other than 0 or 90
You're right I'm not clear. You thought I' am using text() from matplotlib but If I'm looking to the text() invocation from the module Axes3D: Axes3D.text(x, y, z, s, zdir=None, **kwargs)¶ Add text to the plot. kwargs will be passed on to Axes.text, except for the zdir keyword, which sets the direction to be used as the z direction. In my case: ax. text(23.1, 14.0, 340.0, 'ABETI', color='red') Anyway, now I've replaced GTK backend by GTKagg backend, and Everything seems better. Alan De : ben.v.r...@gmail.com [ben.v.r...@gmail.com] de la part de Benjamin Root [ben.r...@ou.edu] Date d'envoi : jeudi 11 août 2011 19:54 À : WALTER Alain Cc : matplotlib-users@lists.sourceforge.net Objet : Re: RE : [Matplotlib-users] unable to draw text at angles other than 0 or 90 On Thu, Aug 11, 2011 at 11:21 AM, WALTER Alain mailto:alain.wal...@thalesgroup.com>> wrote: Hi Ben, I don't want to display rotate text ! I just need to display a simple text to my figure : ax.text(onevolume['long'][i],onevolume['lat'][i],onevolume['upper'][i],onevolume['point'][i],color=linecolor) In addition, I do not understand your remark about GDK, If I remember, I need to use the following modules because FigureCanvas and NavigationToolbar are required. from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar Anyway I cannot reproduce the warning, it is a little bit strange ! Thank you Disregard what I said earlier. I didn't see that you were not trying to rotate your text in the first place. What is an example value for "onevolume['point'][i]"? The function signature for ax.text() is that the first 2 positional arguments are the coordinates, the third is the string to display (I would presume that "onevolume['upper'][i]" has something to do with the text you are displaying). However, the "onevolume['point'][i]" is in the position for the fontdict parameter of the function call. This dictionary overrides the default text properties, which I believe include properties like the rotation angle. Ben Root -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] foreground color versus background color
Hello, I have a graphic, that is built with matpotlib facilities. I display some texts with a color for the text and a color for the corresponding background. I want to optimize the lisibility of such texts, then I shall adapted the background color to the foreground color. For example, when background is 'black', a good foreground is 'white' and conversely, but supposing that foreground colors are randomly allocated, it is rather complicated. Is there any method based on rgb parameters to deduce background color from foreground color ? Thank you -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] where to download module mpl_toolkits.mplot3d.art3d
Hello I 've made some test so as to display a rectangle in a 3d view by using matplotlib methods. I get examples from address http://nullege.com/codes/show/src%40m%40a%40matplotlib-HEAD%40matplotlib%40lib%40mpl_toolkits%40mplot3d%40axes3d.py/881/art3d.Line3DCollection/python import warnings from matplotlib.axes import Axes, rcParams from matplotlib import cbook from matplotlib.transforms import Bbox from matplotlib import collections import numpy as np from matplotlib.colors import Normalize, colorConverter, LightSource import art3d import proj3d import axis3d then I remark that art3d is not included in matplotlib module, but I do not find any way to download art3d from the net. And why "import art3d" rather than "import mpl_toolkits.mplot3d.art3d" ? Is anybody is aware about this topic. Thanks a lot. -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] first step display a 3d volume
Hello, I've developped an application that displays volume by using Axes3d module and plot() method. It runs well. Volumes are expressed in axes x,y,z that represents respectively the latitude,longitude and altitude. Taking a simple volume : a parallelepiped is defined by 2 series of points : A1(x1,y1,z_upper), A2(x2,y2,z_upper), A3(x3,y3,z_upper), A4(x4,y4,z_upper) A11(x1,y1,z_lower), A12(x2,y2,z_lower), A13(x3,y3,z_lower), A14(x4,y4,z_lower) My objective is to displays the faces of such volume (6 faces in that case). I suppose that I should trace my volume face by face and the following source code displays a single surface (a face of my volume): ## import gtk import numpy as np from matplotlib.patches import Polygon, PathPatch import mpl_toolkits.mplot3d.art3d as art3d from matplotlib.figure import Figure from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas class SectorDisplay2__: def __init__(self): win = gtk.Window() win.set_default_size(800,800) vbox = gtk.VBox() win.add(vbox) fig = Figure() canvas = FigureCanvas(fig) # a gtk.DrawingArea ax = fig.add_subplot(111, projection='3d') a = np.array([[0,0],[10,0],[10,10],[0,10]]) p = Polygon(a,fill=True) ax.add_patch(p) art3d.pathpatch_2d_to_3d(p, z=3) ax.set_xlim3d(0, 20) ax.set_ylim3d(0, 20) ax.set_zlim3d(0, 20) vbox.pack_start(canvas) win.show_all() # Run the Gtk mainloop gtk.main() if __name__ == '__main__': SectorDisplay2__() ## But two problems appears : - the intruction "art3d.pathpatch_2d_to_3d(p, z=3)" can be called only once ! else message "AttributeError: 'PathPatch3D' object has no attribute '_path2d'" is issued - the isntruction set_xlim3d(0, 20) has no effect : whatever the values supplied to set_slim3d, the minimum/maximum of axes are defined always by the minimum/maximum of the data to display (coordinates of my points). Thank you for any suggestion (even to represent such volumes in a different way as I choose) -- FREE DOWNLOAD - uberSVN with Social Coding for Subversion. Subversion made easy with a complete admin console. Easy to use, easy to manage, easy to install, easy to extend. Get a Free download of the new open ALM Subversion platform now. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] RE : where to download module mpl_toolkits.mplot3d.art3d
My purpose is explain by a new post more explicitely. Alan De : ben.v.r...@gmail.com [ben.v.r...@gmail.com] de la part de Benjamin Root [ben.r...@ou.edu] Date d'envoi : vendredi 12 août 2011 16:14 À : WALTER Alain Cc : matplotlib-users@lists.sourceforge.net Objet : Re: [Matplotlib-users] where to download module mpl_toolkits.mplot3d.art3d On Friday, August 12, 2011, WALTER Alain mailto:alain.wal...@thalesgroup.com>> wrote: > Hello > I 've made some test so as to display a rectangle in a 3d view by using > matplotlib methods. > I get examples from address > http://nullege.com/codes/show/src%40m%40a%40matplotlib-HEAD%40matplotlib%40lib%40mpl_toolkits%40mplot3d%40axes3d.py/881/art3d.Line3DCollection/python > > import warnings > from matplotlib.axes import Axes, rcParams > from matplotlib import cbook > from matplotlib.transforms import Bbox > from matplotlib import collections > import numpy as np > from matplotlib.colors import Normalize, colorConverter, LightSource > > import art3d > import proj3d > import axis3d > > > then I remark that art3d is not included in matplotlib module, but I do not > find any way to download art3d from the net. And why "import art3d" rather > than "import mpl_toolkits.mplot3d.art3d" ? > Is anybody is aware about this topic. > Thanks a lot. > Since I happen to be the de facto 3d guy around here, I will respond. I think your "example" is actually a bit of test code within the mplot3d module. Because the code is within the same directory as the other files, that code can simply import art3d without specifying the module it resides in. I should also warn you that it seems like you want to use mplot3d for general 3d plotting. Mplot3d is not suitable for this because there are many layering artifacts that can occur. What are you planning to plot? Ben Root -- FREE DOWNLOAD - uberSVN with Social Coding for Subversion. Subversion made easy with a complete admin console. Easy to use, easy to manage, easy to install, easy to extend. Get a Free download of the new open ALM Subversion platform now. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users