@@ -10,23 +10,19 @@ export Figure, plt, matplotlib, pygui, withfig
1010using Compat
1111import Base. show
1212
13- # Wrapper around matplotlib Figure, supporting graphics I/O and pretty display
14- type Figure
15- o:: PyObject
16- end
1713
1814# ##########################################################################
1915# Julia 0.4 help system: define a documentation object
2016# that lazily looks up help from a PyObject via zero or more keys.
2117# This saves us time when loading PyPlot, since we don't have
2218# to load up all of the documentation strings right away.
2319immutable LazyHelp
24- o:: PyObject
20+ o # a PyObject or similar object supporting getindex with a __doc__ key
2521 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)
3026end
3127function show (io:: IO , :: MIME"text/plain" , h:: LazyHelp )
3228 o = h. o
5349include (" init.jl" )
5450
5551# ##########################################################################
56- # Figure methods
52+ # Wrapper around matplotlib Figure, supporting graphics I/O and pretty display
5753
54+ type Figure
55+ o:: PyObject
56+ end
5857PyObject (f:: Figure ) = f. o
5958convert (:: Type{Figure} , o:: PyObject ) = Figure (o)
6059== (f:: Figure , g:: Figure ) = f. o == g. o
@@ -217,67 +216,14 @@ end
217216bar {T<:Symbol} (x:: AbstractVector{T} , y; kws... ) =
218217 bar (map (string, x), y; kws... )
219218
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-
275219# ##########################################################################
276220# Allow plots with 2 independent variables (contour, surf, ...)
277221# to accept either 2 1d arrays or a row vector and a 1d array,
278222# to simplify construction of such plots via broadcasting operations.
279223# (Matplotlib is inconsistent about this.)
280224
225+ include (" plot3d.jl" )
226+
281227for f in (:contour , :contourf )
282228 @eval function $f (X:: AbstractMatrix , Y:: AbstractVector , args... ; kws... )
283229 if size (X,1 ) == 1 || size (X,2 ) == 1
0 commit comments