qwt fixes and examples
@ -1,11 +1,4 @@
|
|||||||
# Examples for backend: qwt
|
## Examples for backend: qwt
|
||||||
|
|
||||||
- Supported arguments: `annotation`, `axis`, `background_color`, `color`, `color_palette`, `fillrange`, `fillcolor`, `foreground_color`, `group`, `heatmap_c`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `pos`, `reg`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yrightlabel`, `yticks`, `xscale`, `yscale`
|
|
||||||
- Supported values for axis: `:auto`, `:left`, `:right`
|
|
||||||
- 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`, `:dashdotdot`
|
|
||||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:star2`, `:hexagon`
|
|
||||||
- Is `subplot`/`subplot!` supported? Yes
|
|
||||||
|
|
||||||
### Initialize
|
### Initialize
|
||||||
|
|
||||||
@ -24,22 +17,31 @@ plot(fakedata(50,5),w=3)
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 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}.
|
||||||
|
|
||||||
|
Get series data: `x, y = plt[i]`. Set series data: `plt[i] = (x,y)`. Add to the series with `push!`/`append!`.
|
||||||
|
|
||||||
|
Easily build animations. (`convert` or `ffmpeg` must be available to generate the animation.) Use command `gif(anim, filename, fps=15)` to save the animation.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(0:0.01:4π,[sin,cos])
|
p = plot([sin,cos],zeros(0),leg=false)
|
||||||
|
anim = Animation()
|
||||||
|
for x = linspace(0,10π,200) # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 43:
|
||||||
|
push!(p,x,Float64[sin(x),cos(x)]) # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 44:
|
||||||
|
frame(anim)
|
||||||
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
###
|
### Parametric plots
|
||||||
|
|
||||||
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
|
Plot function pair (x(u), y(u)).
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 40:
|
plot(sin,(x->begin # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 50:
|
||||||
sin(2x)
|
sin(2x)
|
||||||
end),0,2π,line=4,leg=false,fill=(0,:orange))
|
end),0,2π,line=4,leg=false,fill=(0,:orange))
|
||||||
```
|
```
|
||||||
@ -63,7 +65,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!`
|
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
|
```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)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -75,7 +79,7 @@ Use the `axis` arguments.
|
|||||||
Note: Currently only supported with Qwt and PyPlot
|
Note: Currently only supported with Qwt and PyPlot
|
||||||
|
|
||||||
```julia
|
```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")
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -85,7 +89,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.
|
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
|
```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]))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -140,7 +144,7 @@ plot(x,y,line=(types,3),lab=map(string,types),ms=15)
|
|||||||
|
|
||||||
```julia
|
```julia
|
||||||
styles = setdiff(supportedStyles(),[:auto])'
|
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)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -150,8 +154,11 @@ plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=
|
|||||||
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
markers = setdiff(supportedMarkers(),[:none,:auto])'
|
markers = setdiff(supportedMarkers(),[:none,:auto,Shape])'
|
||||||
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),ms=12)
|
n = length(markers)
|
||||||
|
x = (linspace(0,10,n + 2))[2:end - 1]
|
||||||
|
y = repmat(reverse(x)',n,1)
|
||||||
|
scatter(x,y,m=(8,:auto),lab=map(string,markers),bg=:linen)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -215,9 +222,17 @@ Currently only text annotations are supported. Pass in a tuple or vector-of-tup
|
|||||||
|
|
||||||
```julia
|
```julia
|
||||||
y = rand(10)
|
y = rand(10)
|
||||||
plot(y,ann=(3,y[3],"this is #3"))
|
plot(y,ann=(3,y[3],text("this is #3",:left)))
|
||||||
annotate!([(5,y[5],"this is #5"),(9,y[10],"this is #10")])
|
annotate!([(5,y[5],text("this is #5",16,:red,:center)),(10,y[10],text("this is #10",:right,20,"courier"))])
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
- Supported arguments: `annotation`, `axis`, `background_color`, `color`, `color_palette`, `fillcolor`, `fillrange`, `foreground_color`, `group`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markercolor`, `markershape`, `markersize`, `n`, `nbins`, `nc`, `nr`, `pos`, `show`, `size`, `smooth`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xscale`, `xticks`, `y`, `ylabel`, `ylims`, `yrightlabel`, `yscale`, `yticks`
|
||||||
|
- Supported values for axis: `:auto`, `:left`, `:right`
|
||||||
|
- Supported values for linetype: `:bar`, `:heatmap`, `:hexbin`, `:hist`, `:hline`, `:line`, `:none`, `:path`, `:scatter`, `:steppost`, `:steppre`, `:sticks`, `:vline`
|
||||||
|
- Supported values for linestyle: `:auto`, `:dash`, `:dashdot`, `:dashdotdot`, `:dot`, `:solid`
|
||||||
|
- Supported values for marker: `:auto`, `:cross`, `:diamond`, `:dtriangle`, `:ellipse`, `:hexagon`, `:none`, `:rect`, `:star5`, `:star8`, `:utriangle`, `:xcross`
|
||||||
|
- Is `subplot`/`subplot!` supported? Yes
|
||||||
|
|
||||||
|
(Automatically generated: 2015-10-18T00:40:24)
|
||||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 30 KiB |
BIN
img/qwt/qwt_example_2.gif
Normal file
|
After Width: | Height: | Size: 565 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 8.0 KiB |
@ -120,6 +120,9 @@ function adjustQwtKeywords(plt::Plot{QwtPackage}, iscreating::Bool; kw...)
|
|||||||
d[_qwtAliases[k]] = d[k]
|
d[_qwtAliases[k]] = d[k]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
d[:x] = collect(d[:x])
|
||||||
|
d[:y] = collect(d[:y])
|
||||||
|
|
||||||
d
|
d
|
||||||
end
|
end
|
||||||
@ -212,6 +215,16 @@ function addLineMarker(plt::Plot{QwtPackage}, d::Dict)
|
|||||||
# marker[:attach](plt.o.widget)
|
# marker[:attach](plt.o.widget)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function createQwtAnnotation(plt::Plot, x, y, val::PlotText)
|
||||||
|
marker = Qwt.QWT.QwtPlotMarker()
|
||||||
|
marker[:setValue](x, y)
|
||||||
|
qwttext = Qwt.QWT.QwtText(val.str)
|
||||||
|
qwttext[:setFont](Qwt.QT.QFont(val.font.family, val.font.pointsize))
|
||||||
|
qwttext[:setColor](Qwt.convertRGBToQColor(getColor(val.font.color)))
|
||||||
|
marker[:setLabel](qwttext)
|
||||||
|
marker[:attach](plt.o.widget)
|
||||||
|
end
|
||||||
|
|
||||||
function createQwtAnnotation(plt::Plot, x, y, val::@compat(AbstractString))
|
function createQwtAnnotation(plt::Plot, x, y, val::@compat(AbstractString))
|
||||||
marker = Qwt.QWT.QwtPlotMarker()
|
marker = Qwt.QWT.QwtPlotMarker()
|
||||||
marker[:setValue](x, y)
|
marker[:setValue](x, y)
|
||||||
|
|||||||
@ -116,6 +116,11 @@ function plot!(plt::Plot, args...; kw...)
|
|||||||
setTicksFromStringVector(d, di, :x, :xticks)
|
setTicksFromStringVector(d, di, :x, :xticks)
|
||||||
setTicksFromStringVector(d, di, :y, :yticks)
|
setTicksFromStringVector(d, di, :y, :yticks)
|
||||||
|
|
||||||
|
# remove plot args
|
||||||
|
for k in keys(_plotDefaults)
|
||||||
|
delete!(di, k)
|
||||||
|
end
|
||||||
|
|
||||||
dumpdict(di, "Series $i")
|
dumpdict(di, "Series $i")
|
||||||
|
|
||||||
plot!(plt.backend, plt; di...)
|
plot!(plt.backend, plt; di...)
|
||||||
@ -281,9 +286,9 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
|||||||
# build the series arg dict
|
# build the series arg dict
|
||||||
numUncounted = get(d, :numUncounted, 0)
|
numUncounted = get(d, :numUncounted, 0)
|
||||||
n = plt.n + i + numUncounted
|
n = plt.n + i + numUncounted
|
||||||
dumpdict(d, "before getSeriesArgs")
|
# dumpdict(d, "before getSeriesArgs")
|
||||||
d = getSeriesArgs(plt.backend, getinitargs(plt, n), d, i + numUncounted, convertSeriesIndex(plt, n), n)
|
d = getSeriesArgs(plt.backend, getinitargs(plt, n), d, i + numUncounted, convertSeriesIndex(plt, n), n)
|
||||||
dumpdict(d, "after getSeriesArgs")
|
# dumpdict(d, "after getSeriesArgs")
|
||||||
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
||||||
|
|
||||||
if haskey(d, :idxfilter)
|
if haskey(d, :idxfilter)
|
||||||
|
|||||||