@@ -10,23 +10,19 @@ export Figure, plt, matplotlib, pygui, withfig
10
10
using Compat
11
11
import Base. show
12
12
13
- # Wrapper around matplotlib Figure, supporting graphics I/O and pretty display
14
- type Figure
15
- o:: PyObject
16
- end
17
13
18
14
# ##########################################################################
19
15
# Julia 0.4 help system: define a documentation object
20
16
# that lazily looks up help from a PyObject via zero or more keys.
21
17
# This saves us time when loading PyPlot, since we don't have
22
18
# to load up all of the documentation strings right away.
23
19
immutable LazyHelp
24
- o:: PyObject
20
+ o # a PyObject or similar object supporting getindex with a __doc__ key
25
21
keys:: Tuple{Vararg{String}}
26
- LazyHelp (o:: PyObject ) = new (o, ())
27
- LazyHelp (o:: PyObject , k:: AbstractString ) = new (o, (k,))
28
- LazyHelp (o:: PyObject , k1:: AbstractString , k2:: AbstractString ) = new (o, (k1,k2))
29
- LazyHelp (o:: PyObject , k:: Tuple{Vararg{AbstractString}} ) = new (o, k)
22
+ LazyHelp (o) = new (o, ())
23
+ LazyHelp (o, k:: AbstractString ) = new (o, (k,))
24
+ LazyHelp (o, k1:: AbstractString , k2:: AbstractString ) = new (o, (k1,k2))
25
+ LazyHelp (o, k:: Tuple{Vararg{AbstractString}} ) = new (o, k)
30
26
end
31
27
function show (io:: IO , :: MIME"text/plain" , h:: LazyHelp )
32
28
o = h. o
53
49
include (" init.jl" )
54
50
55
51
# ##########################################################################
56
- # Figure methods
52
+ # Wrapper around matplotlib Figure, supporting graphics I/O and pretty display
57
53
54
+ type Figure
55
+ o:: PyObject
56
+ end
58
57
PyObject (f:: Figure ) = f. o
59
58
convert (:: Type{Figure} , o:: PyObject ) = Figure (o)
60
59
== (f:: Figure , g:: Figure ) = f. o == g. o
@@ -217,67 +216,14 @@ end
217
216
bar {T<:Symbol} (x:: AbstractVector{T} , y; kws... ) =
218
217
bar (map (string, x), y; kws... )
219
218
220
- # ##########################################################################
221
- # Include mplot3d for 3d plotting.
222
-
223
- export art3D, Axes3D, surf, mesh, bar3D, contour3D, contourf3D, plot3D, plot_surface, plot_trisurf, plot_wireframe, scatter3D, text2D, text3D, zlabel, zlim, zscale, zticks
224
-
225
- const mplot3d_funcs = (:bar3d , :contour3D , :contourf3D , :plot3D , :plot_surface ,
226
- :plot_trisurf , :plot_wireframe , :scatter3D ,
227
- :text2D , :text3D )
228
-
229
- for f in mplot3d_funcs
230
- fs = string (f)
231
- @eval @doc LazyHelp (axes3D," Axes3D" , $ fs) function $f (args... ; kws... )
232
- ax = gca (projection= " 3d" )
233
- pycall (ax[$ fs], PyAny, args... ; kws... )
234
- end
235
- end
236
-
237
- # TODO : in Julia 0.4, change this to a callable object
238
- @doc LazyHelp (axes3D," Axes3D" ) Axes3D (args... ; kws... ) = pycall (axes3D[" Axes3D" ], PyAny, args... ; kws... )
239
-
240
- # correct for annoying mplot3d inconsistency
241
- @doc LazyHelp (axes3D," Axes3D" , " bar3d" ) bar3D (args... ) = bar3d (args... )
242
-
243
- # it's annoying to have xlabel etc. but not zlabel
244
- const zlabel_funcs = (:zlabel , :zlim , :zscale , :zticks )
245
- for f in zlabel_funcs
246
- fs = string (" set_" , f)
247
- @eval @doc LazyHelp (axes3D," Axes3D" , $ fs) function $f (args... ; kws... )
248
- ax = gca (projection= " 3d" )
249
- pycall (ax[$ fs], PyAny, args... ; kws... )
250
- end
251
- end
252
-
253
- # export Matlab-like names
254
-
255
- function surf (Z:: AbstractMatrix ; kws... )
256
- plot_surface ([1 : size (Z,1 );]* ones (1 ,size (Z,2 )),
257
- ones (size (Z,1 ))* [1 : size (Z,2 );]' , Z; kws... )
258
- end
259
-
260
- @doc LazyHelp (axes3D," Axes3D" , " plot_surface" ) function surf (X, Y, Z:: AbstractMatrix , args... ; kws... )
261
- plot_surface (X, Y, Z, args... ; kws... )
262
- end
263
-
264
- function surf (X, Y, Z:: AbstractVector , args... ; kws... )
265
- plot_trisurf (X, Y, Z, args... ; kws... )
266
- end
267
-
268
- @doc LazyHelp (axes3D," Axes3D" , " plot_wireframe" ) mesh (args... ; kws... ) = plot_wireframe (args... ; kws... )
269
-
270
- function mesh (Z:: AbstractMatrix ; kws... )
271
- plot_wireframe ([1 : size (Z,1 );]* ones (1 ,size (Z,2 )),
272
- ones (size (Z,1 ))* [1 : size (Z,2 );]' , Z; kws... )
273
- end
274
-
275
219
# ##########################################################################
276
220
# Allow plots with 2 independent variables (contour, surf, ...)
277
221
# to accept either 2 1d arrays or a row vector and a 1d array,
278
222
# to simplify construction of such plots via broadcasting operations.
279
223
# (Matplotlib is inconsistent about this.)
280
224
225
+ include (" plot3d.jl" )
226
+
281
227
for f in (:contour , :contourf )
282
228
@eval function $f (X:: AbstractMatrix , Y:: AbstractVector , args... ; kws... )
283
229
if size (X,1 ) == 1 || size (X,2 ) == 1
0 commit comments