Changeset 9ec9c67 in sasmodels
- Timestamp:
- Feb 6, 2019 5:09:52 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3d7f364
- Parents:
- b1c49601
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/jitter.py
rb1c49601 r9ec9c67 1110 1110 } 1111 1111 def ipv_fix_color(kw): 1112 kw.pop('alpha', None)1112 alpha = kw.pop('alpha', None) 1113 1113 color = kw.get('color', None) 1114 1114 if isinstance(color, str): 1115 1115 color = _IPV_COLORS.get(color, color) 1116 1116 kw['color'] = color 1117 if alpha is not None: 1118 color = kw['color'] 1119 #TODO: convert color to [r, g, b, a] if not already 1120 if isinstance(color, np.ndarray) and color.shape[-1] == 4: 1121 color[..., 3] = alpha 1122 kw['color'] = color 1123 1124 def ipv_set_transparency(kw, obj): 1125 color = kw.get('color', None) 1126 if (isinstance(color, np.ndarray) 1127 and color.shape[-1] == 4 1128 and (color[..., 3] != 1.0).any()): 1129 obj.material.transparent = True 1130 obj.material.side = "FrontSide" 1117 1131 1118 1132 def ipv_axes(): … … 1120 1134 1121 1135 class Plotter: 1136 # transparency can be achieved by setting the following: 1137 # mesh.color = [r, g, b, alpha] 1138 # mesh.material.transparent = True 1139 # mesh.material.side = "FrontSide" 1140 # smooth(ish) rotation can be achieved by setting: 1141 # slide.continuous_update = True 1142 # figure.animation = 0. 1143 # mesh.material.x = x 1144 # mesh.material.y = y 1145 # mesh.material.z = z 1146 # maybe need to synchronize update of x/y/z to avoid shimmy when moving 1122 1147 def plot(self, x, y, z, **kw): 1123 1148 ipv_fix_color(kw) … … 1130 1155 ipv_fix_color(kw) 1131 1156 x, y, z = make_vec(x, y, z) 1132 ipv.plot_surface(x, y, z, **kw) 1157 h = ipv.plot_surface(x, y, z, **kw) 1158 ipv_set_transparency(kw, h) 1159 return h 1133 1160 def plot_trisurf(self, x, y, triangles=None, Z=None, **kw): 1134 1161 ipv_fix_color(kw) … … 1136 1163 if triangles is not None: 1137 1164 triangles = np.asarray(triangles) 1138 ipv.plot_trisurf(x, y, z, triangles=triangles, **kw) 1165 h = ipv.plot_trisurf(x, y, z, triangles=triangles, **kw) 1166 ipv_set_transparency(kw, h) 1167 return h 1139 1168 def scatter(self, x, y, z, **kw): 1140 1169 x, y, z = make_vec(x, y, z) … … 1142 1171 marker = kw.get('marker', None) 1143 1172 kw['marker'] = _IPV_MARKERS.get(marker, marker) 1144 ipv.scatter(x, y, z, **kw) 1173 h = ipv.scatter(x, y, z, **kw) 1174 ipv_set_transparency(kw, h) 1175 return h 1145 1176 def contourf(self, x, y, v, zdir='z', offset=0, levels=None, **kw): 1146 1177 # Don't use contour for now (although we might want to later) … … 1156 1187 u = np.array([[0., 1], [0, 1]]) 1157 1188 v = np.array([[0., 0], [1, 1]]) 1158 ipv.plot_mesh(x, y, z, u=u, v=v, texture=image, wireframe=False) 1189 h = ipv.plot_mesh(x, y, z, u=u, v=v, texture=image, wireframe=False) 1190 ipv_set_transparency(kw, h) 1191 return h 1159 1192 def text(self, *args, **kw): 1160 1193 pass … … 1181 1214 #print(ipv.gcf().__dict__.keys()) 1182 1215 #print(dir(ipv.gcf())) 1183 ipv.figure( )1216 ipv.figure(animation=0.) # no animation when updating object mesh 1184 1217 1185 1218 # set small jitter as 0 if multiple pd dims … … 1235 1268 description=name, 1236 1269 disabled=False, 1270 #continuous_update=True, 1237 1271 continuous_update=False, 1238 1272 orientation='horizontal',
Note: See TracChangeset
for help on using the changeset viewer.