diff --git a/docs/example_generation.jl b/docs/example_generation.jl index 5dd9568d..d7369229 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -35,9 +35,9 @@ const examples = PlotExample[ :(plot(fakedata(50,5), w=3)) ]), PlotExample("Functions, adding data, and animations", - "Plot multiple functions. You can also put the function first, or use the form `plot(f, xmin, xmax)` where f is a Function or AbstractVector{Function}. Set, get, and push/append to series data, and easily build animations.\n\nNote: ImageMagick's `convert` or `ffmpeg` must be runnable from pwd to generate the animation.", + "Plot multiple functions. You can also put the function first, or use the form `plot(f, xmin, xmax)` where f is a Function or AbstractVector{Function}. Set, get, and push/append to series data, and easily build animations.\n\nNote: ImageMagick's `convert` or `ffmpeg` must be runnable from pwd to generate the animation. Use command `gif(anim, filename, fps=15)` to save the animation.", [ - :(p = plot([sin,cos], zeros(0))), + :(p = plot([sin,cos], zeros(0), leg=false)), :(anim = Animation()), :(for x in linspace(0, 10π, 200) push!(p, x, Float64[sin(x), cos(x)]) diff --git a/docs/gadfly_examples.md b/docs/gadfly_examples.md index f4251c22..784311d2 100644 --- a/docs/gadfly_examples.md +++ b/docs/gadfly_examples.md @@ -1,6 +1,6 @@ # Examples for backend: gadfly -- Supported arguments: `annotation`, `background_color`, `color`, `color_palette`, `fillrange`, `fillcolor`, `foreground_color`, `group`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `smooth`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yticks`, `xscale`, `yscale`, `xflip`, `yflip`, `z`, `tickfont`, `guidefont`, `legendfont` +- Supported arguments: `annotation`, `background_color`, `color`, `color_palette`, `fillrange`, `fillcolor`, `fillopacity`, `foreground_color`, `group`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `lineopacity`, `markershape`, `markercolor`, `markersize`, `markeropacity`, `n`, `nbins`, `nc`, `nr`, `smooth`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yticks`, `xscale`, `yscale`, `xflip`, `yflip`, `z`, `tickfont`, `guidefont`, `legendfont`, `grid` - Supported values for axis: `:auto`, `:left` - Supported values for linetype: `:none`, `:line`, `:path`, `:steppre`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`, `:ohlc` - Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot` @@ -24,22 +24,29 @@ plot(fakedata(50,5),w=3) ![](../img/gadfly/gadfly_example_1.png) -### Functions +### Functions, adding data, and animations -Plot multiple functions. You can also put the function first, or use the form `plot(f, xmin, xmax)` where f is a Function or AbstractVector{Function}. +Plot multiple functions. You can also put the function first, or use the form `plot(f, xmin, xmax)` where f is a Function or AbstractVector{Function}. Set, get, and push/append to series data, and easily build animations. + +Note: ImageMagick's `convert` or `ffmpeg` must be runnable from pwd to generate the animation. ```julia -plot(0:0.01:4π,[sin,cos]) +p = plot([sin,cos],zeros(0)) +anim = Animation() +for x = linspace(0,10π,200) # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 43: + push!(p,x,Float64[sin(x),cos(x)]) # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 44: + frame(anim) +end ``` -![](../img/gadfly/gadfly_example_2.png) +![](../img/gadfly/gadfly_example_2.gif) ### Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax). ```julia -plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 40: +plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 50: sin(2x) end),0,2π,line=4,leg=false,fill=(0,:orange)) ``` @@ -63,7 +70,9 @@ scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad") Change the guides/background/limits/ticks. Convenience args `xaxis` and `yaxis` allow you to pass a tuple or value which will be mapped to the relevant args automatically. The `xaxis` below will be replaced with `xlabel` and `xlims` args automatically during the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!`, `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!` ```julia -plot(rand(20,3),title="TITLE",xaxis=("XLABEL",(-5,30),0:2:20,:flip),yaxis=("YLABEL",:log10),background_color=RGB(0.2,0.2,0.2),leg=false) +plot(rand(20,3),xaxis=("XLABEL",(-5,30),0:2:20,:flip),background_color=RGB(0.2,0.2,0.2),leg=false) +title!("TITLE") +yaxis!("YLABEL",:log10) ``` ![](../img/gadfly/gadfly_example_5.png) @@ -75,7 +84,7 @@ Use the `axis` arguments. Note: Currently only supported with Qwt and PyPlot ```julia -plot(Vector[randn(100),randn(100) * 100]; axis=[:l :r],ylabel="LEFT",yrightlabel="RIGHT") +plot(Vector[randn(100),randn(100) * 100],axis=[:l :r],ylabel="LEFT",yrightlabel="RIGHT") ``` ![](../img/gadfly/gadfly_example_6.png) @@ -85,7 +94,7 @@ plot(Vector[randn(100),randn(100) * 100]; axis=[:l :r],ylabel="LEFT",yrightlabel Plot multiple series with different numbers of points. Mix arguments that apply to all series (marker/markersize) with arguments unique to each series (colors). Special arguments `line`, `marker`, and `fill` will automatically figure out what arguments to set (for example, we are setting the `linestyle`, `linewidth`, and `color` arguments with `line`.) Note that we pass a matrix of colors, and this applies the colors to each series. ```julia -plot(Vector[rand(10),rand(20)]; marker=(:ellipse,8),line=(:dot,3,[:black :orange])) +plot(Vector[rand(10),rand(20)],marker=(:ellipse,8),line=(:dot,3,[:black :orange])) ``` ![](../img/gadfly/gadfly_example_7.png) @@ -140,7 +149,7 @@ plot(x,y,line=(types,3),lab=map(string,types),ms=15) ```julia styles = setdiff(supportedStyles(),[:auto])' -plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=5) +plot(cumsum(randn(20,length(styles)),1),style=:auto,label=map(string,styles),w=5) ``` ![](../img/gadfly/gadfly_example_12.png) diff --git a/docs/pyplot_examples.md b/docs/pyplot_examples.md index d2e21b45..6d8219bc 100644 --- a/docs/pyplot_examples.md +++ b/docs/pyplot_examples.md @@ -2,10 +2,10 @@ - Supported arguments: `annotation`, `axis`, `background_color`, `color`, `color_palette`, `fillrange`, `fillcolor`, `foreground_color`, `group`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yrightlabel`, `yticks`, `xscale`, `yscale`, `xflip`, `yflip`, `z` - Supported values for axis: `:auto`, `:left`, `:right` -- Supported values for linetype: `:none`, `:line`, `:path`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline` +- Supported values for linetype: `:none`, `:line`, `:path`, `:steppre`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline` - Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot` -- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:hexagon` -- Is `subplot`/`subplot!` supported? No +- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star5`, `:hexagon` +- Is `subplot`/`subplot!` supported? Yes ### Initialize @@ -24,22 +24,29 @@ plot(fakedata(50,5),w=3) ![](../img/pyplot/pyplot_example_1.png) -### Functions +### Functions, adding data, and animations -Plot multiple functions. You can also put the function first, or use the form `plot(f, xmin, xmax)` where f is a Function or AbstractVector{Function}. +Plot multiple functions. You can also put the function first, or use the form `plot(f, xmin, xmax)` where f is a Function or AbstractVector{Function}. Set, get, and push/append to series data, and easily build animations. + +Note: ImageMagick's `convert` or `ffmpeg` must be runnable from pwd to generate the animation. Use command `gif(anim, filename, fps=15)` to save the animation. ```julia -plot(0:0.01:4π,[sin,cos]) +p = plot([sin,cos],zeros(0),leg=false) +anim = Animation() +for x = linspace(0,10π,200) # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 43: + push!(p,x,Float64[sin(x),cos(x)]) # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 44: + frame(anim) +end ``` -![](../img/pyplot/pyplot_example_2.png) +![](../img/pyplot/pyplot_example_2.gif) ### Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax). ```julia -plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 40: +plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 50: sin(2x) end),0,2π,line=4,leg=false,fill=(0,:orange)) ``` @@ -63,7 +70,9 @@ scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad") Change the guides/background/limits/ticks. Convenience args `xaxis` and `yaxis` allow you to pass a tuple or value which will be mapped to the relevant args automatically. The `xaxis` below will be replaced with `xlabel` and `xlims` args automatically during the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!`, `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!` ```julia -plot(rand(20,3),title="TITLE",xaxis=("XLABEL",(-5,30),0:2:20,:flip),yaxis=("YLABEL",:log10),background_color=RGB(0.2,0.2,0.2),leg=false) +plot(rand(20,3),xaxis=("XLABEL",(-5,30),0:2:20,:flip),background_color=RGB(0.2,0.2,0.2),leg=false) +title!("TITLE") +yaxis!("YLABEL",:log10) ``` ![](../img/pyplot/pyplot_example_5.png) @@ -75,7 +84,7 @@ Use the `axis` arguments. Note: Currently only supported with Qwt and PyPlot ```julia -plot(Vector[randn(100),randn(100) * 100]; axis=[:l :r],ylabel="LEFT",yrightlabel="RIGHT") +plot(Vector[randn(100),randn(100) * 100],axis=[:l :r],ylabel="LEFT",yrightlabel="RIGHT") ``` ![](../img/pyplot/pyplot_example_6.png) @@ -85,7 +94,7 @@ plot(Vector[randn(100),randn(100) * 100]; axis=[:l :r],ylabel="LEFT",yrightlabel Plot multiple series with different numbers of points. Mix arguments that apply to all series (marker/markersize) with arguments unique to each series (colors). Special arguments `line`, `marker`, and `fill` will automatically figure out what arguments to set (for example, we are setting the `linestyle`, `linewidth`, and `color` arguments with `line`.) Note that we pass a matrix of colors, and this applies the colors to each series. ```julia -plot(Vector[rand(10),rand(20)]; marker=(:ellipse,8),line=(:dot,3,[:black :orange])) +plot(Vector[rand(10),rand(20)],marker=(:ellipse,8),line=(:dot,3,[:black :orange])) ``` ![](../img/pyplot/pyplot_example_7.png) @@ -140,7 +149,7 @@ plot(x,y,line=(types,3),lab=map(string,types),ms=15) ```julia styles = setdiff(supportedStyles(),[:auto])' -plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=5) +plot(cumsum(randn(20,length(styles)),1),style=:auto,label=map(string,styles),w=5) ``` ![](../img/pyplot/pyplot_example_12.png) @@ -150,8 +159,11 @@ plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w= ```julia -markers = setdiff(supportedMarkers(),[:none,:auto])' -scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),ms=12) +markers = setdiff(supportedMarkers(),[:none,:auto,Shape])' +n = length(markers) +x = (linspace(0,10,n + 2))[2:end - 1] +y = repmat(reverse(x)',n,1) +scatter(x,y,m=(12,:auto),lab=map(string,markers),bg=:linen) ``` ![](../img/pyplot/pyplot_example_13.png) @@ -176,14 +188,47 @@ histogram(randn(1000),nbins=50) ![](../img/pyplot/pyplot_example_15.png) +### Subplots + + subplot and subplot! are distinct commands which create many plots and add series to them in a circular fashion. + You can define the layout with keyword params... either set the number of plots `n` (and optionally number of rows `nr` or + number of columns `nc`), or you can set the layout directly with `layout`. + + +```julia +subplot(randn(100,5),layout=[1,1,3],t=[:line :hist :scatter :step :bar],nbins=10,leg=false) +``` + +![](../img/pyplot/pyplot_example_16.png) + +### Adding to subplots + +Note here the automatic grid layout, as well as the order in which new series are added to the plots. + +```julia +subplot(fakedata(100,10),n=4,palette=[:grays :blues :heat :lightrainbow],bg=[:orange :pink :darkblue :black]) +``` + +![](../img/pyplot/pyplot_example_17.png) + +### + + + +```julia +subplot!(fakedata(100,10)) +``` + +![](../img/pyplot/pyplot_example_18.png) + ### Annotations Currently only text annotations are supported. Pass in a tuple or vector-of-tuples: (x,y,text). `annotate!(ann)` is shorthand for `plot!(; annotation=ann)` ```julia y = rand(10) -plot(y,ann=(3,y[3],"this is #3")) -annotate!([(5,y[5],"this is #5"),(9,y[10],"this is #10")]) +plot(y,ann=(3,y[3],text("this is #3",:left))) +annotate!([(5,y[5],text("this is #5",16,:red,:center)),(10,y[10],text("this is #10",:right,20,"courier"))]) ``` ![](../img/pyplot/pyplot_example_20.png) diff --git a/img/gadfly/gadfly_example_1.png b/img/gadfly/gadfly_example_1.png index a06e42e9..10dcbdba 100644 Binary files a/img/gadfly/gadfly_example_1.png and b/img/gadfly/gadfly_example_1.png differ diff --git a/img/gadfly/gadfly_example_10.png b/img/gadfly/gadfly_example_10.png index e1d4550b..44da0bc8 100644 Binary files a/img/gadfly/gadfly_example_10.png and b/img/gadfly/gadfly_example_10.png differ diff --git a/img/gadfly/gadfly_example_11.png b/img/gadfly/gadfly_example_11.png index c0fa0be1..f8e7343f 100644 Binary files a/img/gadfly/gadfly_example_11.png and b/img/gadfly/gadfly_example_11.png differ diff --git a/img/gadfly/gadfly_example_12.png b/img/gadfly/gadfly_example_12.png index 539bce4a..744e02dd 100644 Binary files a/img/gadfly/gadfly_example_12.png and b/img/gadfly/gadfly_example_12.png differ diff --git a/img/gadfly/gadfly_example_13.png b/img/gadfly/gadfly_example_13.png index 9721d445..55a02314 100644 Binary files a/img/gadfly/gadfly_example_13.png and b/img/gadfly/gadfly_example_13.png differ diff --git a/img/gadfly/gadfly_example_14.png b/img/gadfly/gadfly_example_14.png index 7e3466c7..c4a22494 100644 Binary files a/img/gadfly/gadfly_example_14.png and b/img/gadfly/gadfly_example_14.png differ diff --git a/img/gadfly/gadfly_example_15.png b/img/gadfly/gadfly_example_15.png index 6b85a465..dbd2189d 100644 Binary files a/img/gadfly/gadfly_example_15.png and b/img/gadfly/gadfly_example_15.png differ diff --git a/img/gadfly/gadfly_example_16.png b/img/gadfly/gadfly_example_16.png index 57e27cb9..b3dfa4b2 100644 Binary files a/img/gadfly/gadfly_example_16.png and b/img/gadfly/gadfly_example_16.png differ diff --git a/img/gadfly/gadfly_example_17.png b/img/gadfly/gadfly_example_17.png index a94dd3f8..85f79662 100644 Binary files a/img/gadfly/gadfly_example_17.png and b/img/gadfly/gadfly_example_17.png differ diff --git a/img/gadfly/gadfly_example_18.png b/img/gadfly/gadfly_example_18.png index 8cd1397d..b6731b34 100644 Binary files a/img/gadfly/gadfly_example_18.png and b/img/gadfly/gadfly_example_18.png differ diff --git a/img/gadfly/gadfly_example_2.gif b/img/gadfly/gadfly_example_2.gif new file mode 100644 index 00000000..fd37cc1e Binary files /dev/null and b/img/gadfly/gadfly_example_2.gif differ diff --git a/img/gadfly/gadfly_example_20.png b/img/gadfly/gadfly_example_20.png index 42e2798b..c8e0841a 100644 Binary files a/img/gadfly/gadfly_example_20.png and b/img/gadfly/gadfly_example_20.png differ diff --git a/img/gadfly/gadfly_example_3.png b/img/gadfly/gadfly_example_3.png index ba25ea9d..7e89042e 100644 Binary files a/img/gadfly/gadfly_example_3.png and b/img/gadfly/gadfly_example_3.png differ diff --git a/img/gadfly/gadfly_example_4.png b/img/gadfly/gadfly_example_4.png index 925dc86f..2355d641 100644 Binary files a/img/gadfly/gadfly_example_4.png and b/img/gadfly/gadfly_example_4.png differ diff --git a/img/gadfly/gadfly_example_5.png b/img/gadfly/gadfly_example_5.png index 2fa91efb..af4d7be4 100644 Binary files a/img/gadfly/gadfly_example_5.png and b/img/gadfly/gadfly_example_5.png differ diff --git a/img/gadfly/gadfly_example_6.png b/img/gadfly/gadfly_example_6.png index 7c5911b2..ef5bc874 100644 Binary files a/img/gadfly/gadfly_example_6.png and b/img/gadfly/gadfly_example_6.png differ diff --git a/img/gadfly/gadfly_example_7.png b/img/gadfly/gadfly_example_7.png index 9858dc70..fbf90579 100644 Binary files a/img/gadfly/gadfly_example_7.png and b/img/gadfly/gadfly_example_7.png differ diff --git a/img/gadfly/gadfly_example_8.png b/img/gadfly/gadfly_example_8.png index d5b3b292..e231b473 100644 Binary files a/img/gadfly/gadfly_example_8.png and b/img/gadfly/gadfly_example_8.png differ diff --git a/img/gadfly/gadfly_example_9.png b/img/gadfly/gadfly_example_9.png index 737f0a02..dcee16be 100644 Binary files a/img/gadfly/gadfly_example_9.png and b/img/gadfly/gadfly_example_9.png differ diff --git a/img/pyplot/pyplot_example_1.png b/img/pyplot/pyplot_example_1.png index 1f546559..7fbdc433 100644 Binary files a/img/pyplot/pyplot_example_1.png and b/img/pyplot/pyplot_example_1.png differ diff --git a/img/pyplot/pyplot_example_10.png b/img/pyplot/pyplot_example_10.png index 0ec0321f..63314a21 100644 Binary files a/img/pyplot/pyplot_example_10.png and b/img/pyplot/pyplot_example_10.png differ diff --git a/img/pyplot/pyplot_example_11.png b/img/pyplot/pyplot_example_11.png index a6cc6a4d..7a6d99f9 100644 Binary files a/img/pyplot/pyplot_example_11.png and b/img/pyplot/pyplot_example_11.png differ diff --git a/img/pyplot/pyplot_example_12.png b/img/pyplot/pyplot_example_12.png index d3a81bfa..d79e8469 100644 Binary files a/img/pyplot/pyplot_example_12.png and b/img/pyplot/pyplot_example_12.png differ diff --git a/img/pyplot/pyplot_example_13.png b/img/pyplot/pyplot_example_13.png index 24a9a382..18262398 100644 Binary files a/img/pyplot/pyplot_example_13.png and b/img/pyplot/pyplot_example_13.png differ diff --git a/img/pyplot/pyplot_example_14.png b/img/pyplot/pyplot_example_14.png index 7bbd973f..c89558e4 100644 Binary files a/img/pyplot/pyplot_example_14.png and b/img/pyplot/pyplot_example_14.png differ diff --git a/img/pyplot/pyplot_example_15.png b/img/pyplot/pyplot_example_15.png index c29d0bdb..c3917c00 100644 Binary files a/img/pyplot/pyplot_example_15.png and b/img/pyplot/pyplot_example_15.png differ diff --git a/img/pyplot/pyplot_example_16.png b/img/pyplot/pyplot_example_16.png new file mode 100644 index 00000000..23a60282 Binary files /dev/null and b/img/pyplot/pyplot_example_16.png differ diff --git a/img/pyplot/pyplot_example_17.png b/img/pyplot/pyplot_example_17.png new file mode 100644 index 00000000..95c4427d Binary files /dev/null and b/img/pyplot/pyplot_example_17.png differ diff --git a/img/pyplot/pyplot_example_18.png b/img/pyplot/pyplot_example_18.png new file mode 100644 index 00000000..6bff91e8 Binary files /dev/null and b/img/pyplot/pyplot_example_18.png differ diff --git a/img/pyplot/pyplot_example_2.gif b/img/pyplot/pyplot_example_2.gif new file mode 100644 index 00000000..90b5b64f Binary files /dev/null and b/img/pyplot/pyplot_example_2.gif differ diff --git a/img/pyplot/pyplot_example_20.png b/img/pyplot/pyplot_example_20.png index 0afe8137..293d3131 100644 Binary files a/img/pyplot/pyplot_example_20.png and b/img/pyplot/pyplot_example_20.png differ diff --git a/img/pyplot/pyplot_example_3.png b/img/pyplot/pyplot_example_3.png index f9068f08..9d594608 100644 Binary files a/img/pyplot/pyplot_example_3.png and b/img/pyplot/pyplot_example_3.png differ diff --git a/img/pyplot/pyplot_example_4.png b/img/pyplot/pyplot_example_4.png index 66cffe1b..e61e2669 100644 Binary files a/img/pyplot/pyplot_example_4.png and b/img/pyplot/pyplot_example_4.png differ diff --git a/img/pyplot/pyplot_example_5.png b/img/pyplot/pyplot_example_5.png index 60e4ad2b..ac0d029c 100644 Binary files a/img/pyplot/pyplot_example_5.png and b/img/pyplot/pyplot_example_5.png differ diff --git a/img/pyplot/pyplot_example_6.png b/img/pyplot/pyplot_example_6.png index 778ceb72..41d4ebe2 100644 Binary files a/img/pyplot/pyplot_example_6.png and b/img/pyplot/pyplot_example_6.png differ diff --git a/img/pyplot/pyplot_example_7.png b/img/pyplot/pyplot_example_7.png index 1524de69..db4cdddf 100644 Binary files a/img/pyplot/pyplot_example_7.png and b/img/pyplot/pyplot_example_7.png differ diff --git a/img/pyplot/pyplot_example_8.png b/img/pyplot/pyplot_example_8.png index 61c70e92..185218f6 100644 Binary files a/img/pyplot/pyplot_example_8.png and b/img/pyplot/pyplot_example_8.png differ diff --git a/img/pyplot/pyplot_example_9.png b/img/pyplot/pyplot_example_9.png index a4ca8a0a..cab84480 100644 Binary files a/img/pyplot/pyplot_example_9.png and b/img/pyplot/pyplot_example_9.png differ diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 30bc241f..583ac6e6 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -315,6 +315,38 @@ function plot!(pkg::PyPlotPackage, plt::Plot; kw...) plt end +# ----------------------------------------------------------------- + + +function Base.getindex(plt::Plot{PyPlotPackage}, i::Integer) + series = plt.seriesargs[i][:serieshandle] + series[:get_data]() + # series[:relim]() + # mapping = getGadflyMappings(plt, i)[1] + # mapping[:x], mapping[:y] +end + +function Base.setindex!(plt::Plot{PyPlotPackage}, xy::Tuple, i::Integer) + series = plt.seriesargs[i][:serieshandle] + series[:set_data](xy...) + + ax = series[:axes] + if plt.initargs[:xlims] == :auto + xmin, xmax = ax[:get_xlim]() + ax[:set_xlim](min(xmin, minimum(xy[1])), max(xmax, maximum(xy[1]))) + end + if plt.initargs[:ylims] == :auto + ymin, ymax = ax[:get_ylim]() + ax[:set_ylim](min(ymin, minimum(xy[2])), max(ymax, maximum(xy[2]))) + end + + # getLeftAxis(plt)[:relim]() + # getRightAxis(plt)[:relim]() + # for mapping in getGadflyMappings(plt, i) + # mapping[:x], mapping[:y] = xy + # end + plt +end # ----------------------------------------------------------------- @@ -465,8 +497,8 @@ function addPyPlotLegend(plt::Plot, ax) ax[:legend]([d[:serieshandle] for d in args], [d[:label] for d in args], loc="best", - fontsize = plt.initargs[:legendfont].pointsize, - framealpha = 0.6 + fontsize = plt.initargs[:legendfont].pointsize + # framealpha = 0.6 ) end end