Bonjour,
Avec python 2.7, J'affiche une forme en 3D avec matplotlib, et certains boutons standards de la fenêtre sont inopérants : "reset original view", "back to previous view", "forward to next view". Le bouton "Zoom to rectangle" ne permet pas de tracer un rectangle car le bouton gauche souris est déjà affecté par la rotation standard et le droit par le zoom du graphique.
j'ai fait des tests en encapsulant mon graphique dans une fenêtre gtk, j'ai bien mon graphique mais avec le comportement suivant : je n'ai plus la rotation standard sur le bouton gauche de la souris, j'ai récupéré le fonctionnement standard des boutons "reset original view", "back to previous view", "forward to next view". Donc au final tout ça n'est pas bien clair.
Merci de vos éclaircissements.
Voilà mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
 
fig = plt.figure()
 
ax = Axes3D(fig)
#get lines as csv description	
line = ""
line = line+"VOL1;P4120;0;999;-49.68722222222222;-1.52166666666667;\n"
line = line+"VOL1;P4121;0;999;-49.68722222222222;-2.20722222222222;\n"
line = line+"VOL1;P1421;0;999;-49.23750000000000;-2.20722222222222;\n"
line = line+"VOL1;P1422;0;999;-49.23750000000000;-1.52166666666667;\n"
line = line+"VOL1;P4120;0;999;-49.68722222222222;-1.52166666666667;\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]])
 
plt.show()