|
130 | 130 |
|
131 | 131 |
|
132 | 132 | # some paraboloids plotted on an implicit 2D domain |
133 | | -x,y = np.ogrid[-10:11, -10:11] |
134 | | -z = x*x + y*y |
135 | | -gp.plot3d( ( z, {'legend': 'zplus'}), |
136 | | - (-z, {'legend': 'zminus'}), |
137 | | - (z*2, {'legend': 'zplus2'}), |
| 133 | +xx,yy = np.ogrid[-10:11, -10:11] |
| 134 | +zz = xx*xx + yy*yy |
| 135 | +gp.plot3d( ( zz, {'legend': 'zplus'}), |
| 136 | + (-zz, {'legend': 'zminus'}), |
| 137 | + (zz*2, {'legend': 'zplus2'}), |
138 | 138 |
|
139 | 139 | _with = 'points', title = 'gridded paraboloids', ascii=True, |
140 | 140 | wait = 1) |
141 | 141 |
|
142 | 142 | # 3d, variable color, variable pointsize |
143 | | -th = np.linspace(0, 6*np.pi, 200) |
144 | | -z = np.linspace(0, 5, 200) |
145 | | -size = 0.5 + np.abs(np.cos(th)) |
146 | | -color = np.sin(2*th) |
| 143 | +th2 = np.linspace(0, 6*np.pi, 200) |
| 144 | +zz = np.linspace(0, 5, 200) |
| 145 | +size = 0.5 + np.abs(np.cos(th2)) |
| 146 | +color = np.sin(2*th2) |
147 | 147 |
|
148 | | -gp.plot3d( ( np.cos(th) * np.array([[1,-1]]).T, |
149 | | - np.sin(th) * np.array([[1,-1]]).T, |
150 | | - z, size, color, { 'legend': np.array(('spiral 1', 'spiral 2'))}), |
| 148 | +gp.plot3d( ( np.cos(th2) * np.array([[1,-1]]).T, |
| 149 | + np.sin(th2) * np.array([[1,-1]]).T, |
| 150 | + zz, size, color, { 'legend': np.array(('spiral 1', 'spiral 2'))}), |
151 | 151 |
|
152 | 152 | title = 'double helix', |
153 | 153 | tuplesize = 5, |
|
156 | 156 |
|
157 | 157 |
|
158 | 158 | # implicit domain heat map |
159 | | -x,y = np.ogrid[-10:11, -10:11] |
160 | | -z = x*x + y*y |
161 | | -gp.plot3d(z, |
| 159 | +xx,yy = np.ogrid[-10:11, -10:11] |
| 160 | +zz = xx*xx + yy*yy |
| 161 | +gp.plot3d(zz, |
162 | 162 | title = 'Paraboloid heat map', |
163 | 163 | set = 'view map', |
164 | 164 | _with = 'image', |
165 | 165 | wait = 1) |
166 | 166 |
|
167 | 167 | # same, but as a 2d gp.plot, _with a curve drawn on top for good measure |
168 | | -x,y = np.ogrid[-10:11, -10:11] |
169 | | -z = x*x + y*y |
170 | | -x = np.linspace(0,20,100) |
171 | | -gp.plot( ( z, {'tuplesize': 3, |
| 168 | +xx,yy = np.ogrid[-10:11, -10:11] |
| 169 | +zz = xx*xx + yy*yy |
| 170 | +xx = np.linspace(0,20,100) |
| 171 | +gp.plot( ( zz, {'tuplesize': 3, |
172 | 172 | 'with': 'image'}), |
173 | | - (x, 20*np.cos(x/20 * np.pi/2), |
| 173 | + (xx, 20*np.cos(xx/20 * np.pi/2), |
174 | 174 |
|
175 | 175 | {'tuplesize': 2, |
176 | 176 | 'with': 'lines'}), |
|
187 | 187 | ################################ |
188 | 188 | # 2D implicit domain demos |
189 | 189 | ################################ |
190 | | -x,y = np.mgrid[-10:11, -10:11] |
191 | | -z = np.sqrt(x*x + y*y) |
| 190 | +xx,yy = np.mgrid[-10:11, -10:11] |
| 191 | +zz = np.sqrt(xx*xx + yy*yy) |
192 | 192 |
|
193 | | -x = x[:, 2:12] |
194 | | -z = z[:, 2:12] |
| 193 | +xx = xx[:, 2:12] |
| 194 | +zz = zz[:, 2:12] |
195 | 195 |
|
196 | 196 | # single 3d matrix curve |
197 | | -gp.plot(z, |
| 197 | +gp.plot(zz, |
198 | 198 | title = 'Single 3D matrix plot. Binary.', |
199 | 199 | square = 1, |
200 | 200 | tuplesize = 3, |
|
203 | 203 | wait = 1) |
204 | 204 |
|
205 | 205 | # 4d matrix curve |
206 | | -gp.plot(z, x, |
| 206 | +gp.plot(zz, xx, |
207 | 207 | title = '4D matrix plot. Binary.', |
208 | 208 | square = 1, |
209 | 209 | tuplesize = 4, |
|
212 | 212 | wait = 1) |
213 | 213 |
|
214 | 214 | # Using broadcasting to plot each slice with a different style |
215 | | -gp.plot((np.rollaxis( np.dstack((x,z)), 2,0), |
| 215 | +gp.plot((np.rollaxis( np.dstack((xx,zz)), 2,0), |
216 | 216 | {'tuplesize': 3, |
217 | 217 | 'with': np.array(('points palette pt 7','points ps variable pt 6'))}), |
218 | 218 |
|
|
231 | 231 | # wait = 1) |
232 | 232 | # |
233 | 233 | # 2 3d matrix curves |
234 | | -gp.plot((np.rollaxis( np.dstack((x,z)), 2,0), |
| 234 | +gp.plot((np.rollaxis( np.dstack((xx,zz)), 2,0), |
235 | 235 | {'tuplesize': 3, |
236 | 236 | 'with': np.array(('points palette pt 7','points ps variable pt 6'))}), |
237 | 237 |
|
|
243 | 243 | ################################### |
244 | 244 | # fancy contours just because I can |
245 | 245 | ################################### |
246 | | -y,x = np.mgrid[0:61,0:61] |
247 | | -x -= 30 |
248 | | -y -= 30 |
249 | | -z = np.sin(x / 4.0) * y |
| 246 | +yy,xx = np.mgrid[0:61,0:61] |
| 247 | +xx -= 30 |
| 248 | +yy -= 30 |
| 249 | +zz = np.sin(xx / 4.0) * yy |
250 | 250 |
|
251 | 251 | # single 3d matrix curve. Two plots: the image and the contours together. |
252 | 252 | # Broadcasting the styles |
253 | | -gp.plot3d( (z, {'tuplesize': 3, 'with': np.array(('image','lines'))}), |
| 253 | +gp.plot3d( (zz, {'tuplesize': 3, 'with': np.array(('image','lines'))}), |
254 | 254 |
|
255 | 255 | title = 'matrix plot with contours', |
256 | 256 | cmds = [ 'set contours base', |
|
0 commit comments