added parametric plot with example

This commit is contained in:
Thomas Breloff 2015-09-12 22:02:17 -04:00
parent 5a47864d73
commit 056fee4b28
46 changed files with 90 additions and 41 deletions

View File

@ -26,8 +26,11 @@ const examples = PlotExample[
"Plot multiple functions.",
[:(plot(0:0.01:4π, [sin,cos]))]),
PlotExample("",
"You can also call it with (xmin, xmax).",
"You can also call it with plot(f, xmin, xmax).",
[:(plot([sin,cos], 0, 4π))]),
PlotExample("",
"Or make a parametric plot with plot(fx, fy, umin, umax).",
[:(plot(sin, x->sin(2x), 0, 2π))]),
PlotExample("Global",
"Change the guides/background without a separate call.",
[:(plot(rand(10); title="TITLE", xlabel="XLABEL", ylabel="YLABEL", background_color = RGB(0.5,0.5,0.5)))]),
@ -120,9 +123,9 @@ end
# run it!
# note: generate separately so it's easy to comment out
# generate_markdown(:qwt)
generate_markdown(:qwt)
generate_markdown(:gadfly)
# generate_markdown(:unicodeplots)
generate_markdown(:unicodeplots)
end # module

View File

@ -20,7 +20,7 @@ plot(0:0.01:4π,[sin,cos])
###
You can also call it with (xmin, xmax).
You can also call it with plot(f, xmin, xmax).
```julia
plot([sin,cos],0,4π)
@ -28,6 +28,18 @@ plot([sin,cos],0,4π)
![](../img/gadfly/gadfly_example_3.png)
###
Or make a parametric plot with plot(fx, fy, umin, umax).
```julia
plot(sin,(x->begin # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
sin(2x)
end),0,2π)
```
![](../img/gadfly/gadfly_example_4.png)
### Global
Change the guides/background without a separate call.
@ -36,7 +48,7 @@ Change the guides/background without a separate call.
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.5,0.5,0.5))
```
![](../img/gadfly/gadfly_example_4.png)
![](../img/gadfly/gadfly_example_5.png)
### Two-axis
@ -48,7 +60,7 @@ Note: This is only supported with Qwt right now
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right])
```
![](../img/gadfly/gadfly_example_5.png)
![](../img/gadfly/gadfly_example_6.png)
### Vectors w/ pluralized args
@ -58,7 +70,7 @@ Plot multiple series with different numbers of points. Mix arguments that apply
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue])
```
![](../img/gadfly/gadfly_example_6.png)
![](../img/gadfly/gadfly_example_7.png)
### Build plot in pieces
@ -68,7 +80,7 @@ Start with a base plot...
plot(rand(100) / 3; reg=true,fillto=0)
```
![](../img/gadfly/gadfly_example_7.png)
![](../img/gadfly/gadfly_example_8.png)
###
@ -78,7 +90,7 @@ and add to it later.
scatter!(rand(100); markersize=6,color=:blue)
```
![](../img/gadfly/gadfly_example_8.png)
![](../img/gadfly/gadfly_example_9.png)
### Heatmaps
@ -88,7 +100,7 @@ scatter!(rand(100); markersize=6,color=:blue)
heatmap(randn(10000),randn(10000); nbins=200)
```
![](../img/gadfly/gadfly_example_9.png)
![](../img/gadfly/gadfly_example_10.png)
### Lots of line types
@ -99,7 +111,7 @@ Note: some may not work with all backends
plot(rand(20,4); linetypes=[:line,:step,:sticks,:dots],labels=["line","step","sticks","dots"])
```
![](../img/gadfly/gadfly_example_10.png)
![](../img/gadfly/gadfly_example_11.png)
### Bar
@ -109,7 +121,7 @@ x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints
bar(randn(1000))
```
![](../img/gadfly/gadfly_example_11.png)
![](../img/gadfly/gadfly_example_12.png)
### Histogram
@ -119,7 +131,7 @@ note: fillto isn't supported on all backends
histogram(randn(1000); nbins=50,fillto=20)
```
![](../img/gadfly/gadfly_example_12.png)
![](../img/gadfly/gadfly_example_13.png)
### Subplots
@ -134,7 +146,7 @@ histogram(randn(1000); nbins=50,fillto=20)
subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:dots,:step,:bar],nbins=10,legend=false)
```
![](../img/gadfly/gadfly_example_13.png)
![](../img/gadfly/gadfly_example_14.png)
### Adding to subplots
@ -144,7 +156,7 @@ Note here the automatic grid layout, as well as the order in which new series ar
subplot(randn(100,5); n=4)
```
![](../img/gadfly/gadfly_example_14.png)
![](../img/gadfly/gadfly_example_15.png)
###
@ -154,5 +166,5 @@ subplot(randn(100,5); n=4)
subplot!(randn(100,3))
```
![](../img/gadfly/gadfly_example_15.png)
![](../img/gadfly/gadfly_example_16.png)

View File

@ -20,7 +20,7 @@ plot(0:0.01:4π,[sin,cos])
###
You can also call it with (xmin, xmax).
You can also call it with plot(f, xmin, xmax).
```julia
plot([sin,cos],0,4π)
@ -28,6 +28,18 @@ plot([sin,cos],0,4π)
![](../img/qwt/qwt_example_3.png)
###
Or make a parametric plot with plot(fx, fy, umin, umax).
```julia
plot(sin,(x->begin # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
sin(2x)
end),0,2π)
```
![](../img/qwt/qwt_example_4.png)
### Global
Change the guides/background without a separate call.
@ -36,7 +48,7 @@ Change the guides/background without a separate call.
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.5,0.5,0.5))
```
![](../img/qwt/qwt_example_4.png)
![](../img/qwt/qwt_example_5.png)
### Two-axis
@ -48,7 +60,7 @@ Note: This is only supported with Qwt right now
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right])
```
![](../img/qwt/qwt_example_5.png)
![](../img/qwt/qwt_example_6.png)
### Vectors w/ pluralized args
@ -58,7 +70,7 @@ Plot multiple series with different numbers of points. Mix arguments that apply
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue])
```
![](../img/qwt/qwt_example_6.png)
![](../img/qwt/qwt_example_7.png)
### Build plot in pieces
@ -68,7 +80,7 @@ Start with a base plot...
plot(rand(100) / 3; reg=true,fillto=0)
```
![](../img/qwt/qwt_example_7.png)
![](../img/qwt/qwt_example_8.png)
###
@ -78,7 +90,7 @@ and add to it later.
scatter!(rand(100); markersize=6,color=:blue)
```
![](../img/qwt/qwt_example_8.png)
![](../img/qwt/qwt_example_9.png)
### Heatmaps
@ -88,7 +100,7 @@ scatter!(rand(100); markersize=6,color=:blue)
heatmap(randn(10000),randn(10000); nbins=200)
```
![](../img/qwt/qwt_example_9.png)
![](../img/qwt/qwt_example_10.png)
### Lots of line types
@ -99,7 +111,7 @@ Note: some may not work with all backends
plot(rand(20,4); linetypes=[:line,:step,:sticks,:dots],labels=["line","step","sticks","dots"])
```
![](../img/qwt/qwt_example_10.png)
![](../img/qwt/qwt_example_11.png)
### Bar
@ -109,7 +121,7 @@ x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints
bar(randn(1000))
```
![](../img/qwt/qwt_example_11.png)
![](../img/qwt/qwt_example_12.png)
### Histogram
@ -119,7 +131,7 @@ note: fillto isn't supported on all backends
histogram(randn(1000); nbins=50,fillto=20)
```
![](../img/qwt/qwt_example_12.png)
![](../img/qwt/qwt_example_13.png)
### Subplots
@ -134,7 +146,7 @@ histogram(randn(1000); nbins=50,fillto=20)
subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:dots,:step,:bar],nbins=10,legend=false)
```
![](../img/qwt/qwt_example_13.png)
![](../img/qwt/qwt_example_14.png)
### Adding to subplots
@ -144,7 +156,7 @@ Note here the automatic grid layout, as well as the order in which new series ar
subplot(randn(100,5); n=4)
```
![](../img/qwt/qwt_example_14.png)
![](../img/qwt/qwt_example_15.png)
###
@ -154,5 +166,5 @@ subplot(randn(100,5); n=4)
subplot!(randn(100,3))
```
![](../img/qwt/qwt_example_15.png)
![](../img/qwt/qwt_example_16.png)

View File

@ -20,7 +20,7 @@ plot(0:0.01:4π,[sin,cos])
###
You can also call it with (xmin, xmax).
You can also call it with plot(f, xmin, xmax).
```julia
plot([sin,cos],0,4π)
@ -28,6 +28,18 @@ plot([sin,cos],0,4π)
![](../img/unicodeplots/unicodeplots_example_3.png)
###
Or make a parametric plot with plot(fx, fy, umin, umax).
```julia
plot(sin,(x->begin # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
sin(2x)
end),0,2π)
```
![](../img/unicodeplots/unicodeplots_example_4.png)
### Global
Change the guides/background without a separate call.
@ -36,7 +48,7 @@ Change the guides/background without a separate call.
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.5,0.5,0.5))
```
![](../img/unicodeplots/unicodeplots_example_4.png)
![](../img/unicodeplots/unicodeplots_example_5.png)
### Two-axis
@ -48,7 +60,7 @@ Note: This is only supported with Qwt right now
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right])
```
![](../img/unicodeplots/unicodeplots_example_5.png)
![](../img/unicodeplots/unicodeplots_example_6.png)
### Vectors w/ pluralized args
@ -58,7 +70,7 @@ Plot multiple series with different numbers of points. Mix arguments that apply
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue])
```
![](../img/unicodeplots/unicodeplots_example_6.png)
![](../img/unicodeplots/unicodeplots_example_7.png)
### Build plot in pieces
@ -68,7 +80,7 @@ Start with a base plot...
plot(rand(100) / 3; reg=true,fillto=0)
```
![](../img/unicodeplots/unicodeplots_example_7.png)
![](../img/unicodeplots/unicodeplots_example_8.png)
###
@ -78,7 +90,7 @@ and add to it later.
scatter!(rand(100); markersize=6,color=:blue)
```
![](../img/unicodeplots/unicodeplots_example_8.png)
![](../img/unicodeplots/unicodeplots_example_9.png)
### Lots of line types
@ -89,7 +101,7 @@ Note: some may not work with all backends
plot(rand(20,4); linetypes=[:line,:step,:sticks,:dots],labels=["line","step","sticks","dots"])
```
![](../img/unicodeplots/unicodeplots_example_10.png)
![](../img/unicodeplots/unicodeplots_example_11.png)
### Bar
@ -99,7 +111,7 @@ x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints
bar(randn(1000))
```
![](../img/unicodeplots/unicodeplots_example_11.png)
![](../img/unicodeplots/unicodeplots_example_12.png)
### Histogram
@ -109,7 +121,7 @@ note: fillto isn't supported on all backends
histogram(randn(1000); nbins=50,fillto=20)
```
![](../img/unicodeplots/unicodeplots_example_12.png)
![](../img/unicodeplots/unicodeplots_example_13.png)
### Subplots
@ -124,7 +136,7 @@ histogram(randn(1000); nbins=50,fillto=20)
subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:dots,:step,:bar],nbins=10,legend=false)
```
![](../img/unicodeplots/unicodeplots_example_13.png)
![](../img/unicodeplots/unicodeplots_example_14.png)
### Adding to subplots
@ -134,7 +146,7 @@ Note here the automatic grid layout, as well as the order in which new series ar
subplot(randn(100,5); n=4)
```
![](../img/unicodeplots/unicodeplots_example_14.png)
![](../img/unicodeplots/unicodeplots_example_15.png)
###
@ -144,5 +156,5 @@ subplot(randn(100,5); n=4)
subplot!(randn(100,3))
```
![](../img/unicodeplots/unicodeplots_example_15.png)
![](../img/unicodeplots/unicodeplots_example_16.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/qwt/qwt_example_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -235,6 +235,16 @@ function createKWargsList(plt::PlottingObject, fs::Vector{Function}, xmin::Real,
ret
end
# create 1 series, x = fx(u), y = fy(u); u ∈ [umin, umax]
function createKWargsList(plt::PlottingObject, fx::Function, fy::Function, umin::Real, umax::Real; kw...)
d = getPlotKeywordArgs(kw, 1, plt.n + 1)
width = plt.initargs[:size][1]
u = collect(linspace(umin, umax, width)) # we don't need more than the width
d[:x] = map(fx, u)
d[:y] = map(fy, u)
[d]
end
# create 1 series, y = f(x)
function createKWargsList(plt::PlottingObject, x::AVec, f::Function; kw...)
d = getPlotKeywordArgs(kw, 1, plt.n + 1)