Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6aa56fd30f | |||
| f5a6f129dd | |||
| 5405c1d240 | |||
| 455f85e230 | |||
| fa899a67a7 | |||
| 56cf25eebf | |||
| 1a490551e6 | |||
| 4514802e35 | |||
| a9062b0611 | |||
| eb6b30aab1 | |||
| 922abd7ad3 | |||
| c4596dda75 | |||
| 168b77326b | |||
| f674bba861 | |||
| 6b2e65e738 | |||
| 51021c799d | |||
| 01cb036976 |
@@ -11,8 +11,8 @@ doc"""
|
||||
Holds all data needed for a documentation example... header, description, and plotting expression (Expr)
|
||||
"""
|
||||
type PlotExample
|
||||
header::String
|
||||
desc::String
|
||||
header::AbstractString
|
||||
desc::AbstractString
|
||||
exprs::Vector{Expr}
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ const examples = PlotExample[
|
||||
[:(plot([sin,cos], 0, 4π))]),
|
||||
PlotExample("",
|
||||
"Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).",
|
||||
[:(plot(sin, x->sin(2x), 0, 2π))]),
|
||||
[:(plot(sin, x->sin(2x), 0, 2π, legend=false))]),
|
||||
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)))]),
|
||||
@@ -49,19 +49,19 @@ const examples = PlotExample[
|
||||
PlotExample("Heatmaps",
|
||||
"",
|
||||
[:(heatmap(randn(10000),randn(10000); nbins=100))]),
|
||||
PlotExample("Suported line types",
|
||||
"All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)",
|
||||
PlotExample("Line types",
|
||||
"",
|
||||
[:(types = intersect(supportedTypes(), [:line, :step, :stepinverted, :sticks, :scatter])),
|
||||
:(n = length(types)),
|
||||
:(x = Vector[sort(rand(20)) for i in 1:n]),
|
||||
:(y = rand(20,n)),
|
||||
:(plot(x, y; linetypes=types, labels=map(string,types)))]),
|
||||
PlotExample("Supported line styles",
|
||||
"All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)",
|
||||
[:(styles = setdiff(supportedStyles(), [:auto])), :(plot(rand(20,length(styles)); linestyle=:auto, labels=map(string,styles)))]),
|
||||
PlotExample("Supported marker types",
|
||||
"All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)",
|
||||
[:(markers = setdiff(supportedMarkers(), [:none,:auto])), :(plot([fill(i,10) for i=1:length(markers)]; marker=:auto, labels=map(string,markers), markersize=10))]),
|
||||
PlotExample("Line styles",
|
||||
"",
|
||||
[:(styles = setdiff(supportedStyles(), [:auto])), :(plot(cumsum(randn(20,length(styles)),1); linestyle=:auto, labels=map(string,styles), width=5))]),
|
||||
PlotExample("Marker types",
|
||||
"",
|
||||
[:(markers = setdiff(supportedMarkers(), [:none,:auto])), :(scatter(0.5:9.5, [fill(i-0.5,10) for i=length(markers):-1:1]; marker=:auto, labels=map(string,markers), markersize=10))]),
|
||||
PlotExample("Bar",
|
||||
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
|
||||
[:(bar(randn(1000)))]),
|
||||
@@ -83,6 +83,9 @@ const examples = PlotExample[
|
||||
PlotExample("",
|
||||
"",
|
||||
[:(subplot!(randn(100,3)))]),
|
||||
PlotExample("Open/High/Low/Close",
|
||||
"Create an OHLC chart. Pass in a vector of 4-tuples as your `y` argument. Adjust the tick width with arg `markersize`.",
|
||||
[:(n=20), :(hgt=rand(n)+1), :(bot=randn(n)), :(openpct=rand(n)), :(closepct=rand(n)), :(y = [(openpct[i]*hgt[i]+bot[i], bot[i]+hgt[i], bot[i], closepct[i]*hgt[i]+bot[i]) for i in 1:n]), :(ohlc(y; markersize=8))]),
|
||||
|
||||
|
||||
]
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
- Supported arguments: `args`, `axis`, `color`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `reg`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `ylabel`, `yrightlabel`
|
||||
- Supported values for axis: `:auto`, `:left`
|
||||
- Supported values for linetype: `:line`, `:step`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
|
||||
- Supported values for linetype: `:none`, `:line`, `:step`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`, `:ohlc`
|
||||
- Supported values for linestyle: `:auto`, `:solid`
|
||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:cross`
|
||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:star2`, `:hexagon`
|
||||
- Is `subplot`/`subplot!` supported? Yes
|
||||
|
||||
### Initialize
|
||||
@@ -51,7 +51,7 @@ Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, um
|
||||
```julia
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π)
|
||||
end),0,2π,legend=false)
|
||||
```
|
||||
|
||||

|
||||
@@ -118,9 +118,9 @@ heatmap(randn(10000),randn(10000); nbins=100)
|
||||
|
||||

|
||||
|
||||
### Suported line types
|
||||
### Line types
|
||||
|
||||
|
||||
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
|
||||
|
||||
```julia
|
||||
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
|
||||
@@ -132,9 +132,9 @@ plot(x,y; linetypes=types,labels=map(string,types))
|
||||
|
||||

|
||||
|
||||
### Supported line styles
|
||||
### Line styles
|
||||
|
||||
|
||||
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
|
||||
|
||||
```julia
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
@@ -143,13 +143,13 @@ plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
|
||||
|
||||

|
||||
|
||||
### Supported marker types
|
||||
### Marker types
|
||||
|
||||
|
||||
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
|
||||
|
||||
```julia
|
||||
markers = setdiff(supportedMarkers(),[:none,:auto])
|
||||
plot([fill(i,10) for i = 1:length(markers)]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
```
|
||||
|
||||

|
||||
@@ -209,3 +209,19 @@ subplot!(randn(100,3))
|
||||
|
||||

|
||||
|
||||
### Open/High/Low/Close
|
||||
|
||||
Create an OHLC chart. Pass in a vector of 4-tuples as your `y` argument. Adjust the tick width with arg `markersize`.
|
||||
|
||||
```julia
|
||||
n = 20
|
||||
hgt = rand(n) + 1
|
||||
bot = randn(n)
|
||||
openpct = rand(n)
|
||||
closepct = rand(n)
|
||||
y = [(openpct[i] * hgt[i] + bot[i],bot[i] + hgt[i],bot[i],closepct[i] * hgt[i] + bot[i]) for i = 1:n]
|
||||
ohlc(y; markersize=8)
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
- Supported arguments: `args`, `axis`, `color`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `reg`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `ylabel`, `yrightlabel`
|
||||
- Supported values for axis: `:auto`, `:left`
|
||||
- Supported values for linetype: `:line`, `:step`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
|
||||
- Supported values for linetype: `:none`, `:line`, `:step`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`, `:ohlc`
|
||||
- Supported values for linestyle: `:auto`, `:solid`
|
||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:cross`
|
||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:star2`, `:hexagon`
|
||||
- Is `subplot`/`subplot!` supported? Yes
|
||||
|
||||
### Initialize
|
||||
@@ -51,7 +51,7 @@ Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, um
|
||||
```julia
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π)
|
||||
end),0,2π,legend=false)
|
||||
```
|
||||
|
||||

|
||||
@@ -118,9 +118,9 @@ heatmap(randn(10000),randn(10000); nbins=100)
|
||||
|
||||

|
||||
|
||||
### Suported line types
|
||||
### Line types
|
||||
|
||||
|
||||
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
|
||||
|
||||
```julia
|
||||
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
|
||||
@@ -132,9 +132,9 @@ plot(x,y; linetypes=types,labels=map(string,types))
|
||||
|
||||

|
||||
|
||||
### Supported line styles
|
||||
### Line styles
|
||||
|
||||
|
||||
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
|
||||
|
||||
```julia
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
@@ -143,13 +143,13 @@ plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
|
||||
|
||||

|
||||
|
||||
### Supported marker types
|
||||
### Marker types
|
||||
|
||||
|
||||
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
|
||||
|
||||
```julia
|
||||
markers = setdiff(supportedMarkers(),[:none,:auto])
|
||||
plot([fill(i,10) for i = 1:length(markers)]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
```
|
||||
|
||||

|
||||
@@ -209,3 +209,19 @@ subplot!(randn(100,3))
|
||||
|
||||

|
||||
|
||||
### Open/High/Low/Close
|
||||
|
||||
Create an OHLC chart. Pass in a vector of 4-tuples as your `y` argument. Adjust the tick width with arg `markersize`.
|
||||
|
||||
```julia
|
||||
n = 20
|
||||
hgt = rand(n) + 1
|
||||
bot = randn(n)
|
||||
openpct = rand(n)
|
||||
closepct = rand(n)
|
||||
y = [(openpct[i] * hgt[i] + bot[i],bot[i] + hgt[i],bot[i],closepct[i] * hgt[i] + bot[i]) for i = 1:n]
|
||||
ohlc(y; markersize=8)
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
- Supported values for axis: `:auto`, `:left`, `:right`
|
||||
- Supported values for linetype: `:none`, `:line`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
|
||||
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`
|
||||
- Supported values for marker: `:none`, `:auto`, `:ellipse`, `:rect`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:hexagon`
|
||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:hexagon`
|
||||
- Is `subplot`/`subplot!` supported? No
|
||||
|
||||
### Initialize
|
||||
@@ -51,7 +51,7 @@ Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, um
|
||||
```julia
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π)
|
||||
end),0,2π,legend=false)
|
||||
```
|
||||
|
||||

|
||||
@@ -118,9 +118,9 @@ heatmap(randn(10000),randn(10000); nbins=100)
|
||||
|
||||

|
||||
|
||||
### Suported line types
|
||||
### Line types
|
||||
|
||||
|
||||
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
|
||||
|
||||
```julia
|
||||
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
|
||||
@@ -132,9 +132,9 @@ plot(x,y; linetypes=types,labels=map(string,types))
|
||||
|
||||

|
||||
|
||||
### Supported line styles
|
||||
### Line styles
|
||||
|
||||
|
||||
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
|
||||
|
||||
```julia
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
@@ -143,13 +143,13 @@ plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
|
||||
|
||||

|
||||
|
||||
### Supported marker types
|
||||
### Marker types
|
||||
|
||||
|
||||
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
|
||||
|
||||
```julia
|
||||
markers = setdiff(supportedMarkers(),[:none,:auto])
|
||||
plot([fill(i,10) for i = 1:length(markers)]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -51,7 +51,7 @@ Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, um
|
||||
```julia
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π)
|
||||
end),0,2π,legend=false)
|
||||
```
|
||||
|
||||

|
||||
@@ -118,9 +118,9 @@ heatmap(randn(10000),randn(10000); nbins=100)
|
||||
|
||||

|
||||
|
||||
### Suported line types
|
||||
### Line types
|
||||
|
||||
|
||||
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
|
||||
|
||||
```julia
|
||||
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
|
||||
@@ -132,9 +132,9 @@ plot(x,y; linetypes=types,labels=map(string,types))
|
||||
|
||||

|
||||
|
||||
### Supported line styles
|
||||
### Line styles
|
||||
|
||||
|
||||
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
|
||||
|
||||
```julia
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
@@ -143,13 +143,13 @@ plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
|
||||
|
||||

|
||||
|
||||
### Supported marker types
|
||||
### Marker types
|
||||
|
||||
|
||||
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
|
||||
|
||||
```julia
|
||||
markers = setdiff(supportedMarkers(),[:none,:auto])
|
||||
plot([fill(i,10) for i = 1:length(markers)]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
- Supported arguments: `args`, `axis`, `color`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markersize`, `nbins`, `reg`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `ylabel`, `yrightlabel`
|
||||
- Supported values for axis: `:auto`, `:left`
|
||||
- Supported values for linetype: `:none`, `:line`, `:sticks`, `:scatter`, `:hist`, `:bar`
|
||||
- Supported values for linestyle: `:auto`, `:solid`, `:dashdotdot`, `:dot`, `:dash`, `:dashdot`
|
||||
- Supported values for marker: `:auto`, `:hexagon`, `:none`, `:dtriangle`, `:ellipse`, `:xcross`, `:rect`, `:star1`, `:star2`, `:cross`, `:utriangle`, `:diamond`
|
||||
- Supported values for linestyle: `:solid`, `:dash`, `:dot`, `:dashdot`
|
||||
- Supported values for marker: `:none`, `:ellipse`, `:rect`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`
|
||||
- Is `subplot`/`subplot!` supported? No
|
||||
|
||||
### Initialize
|
||||
@@ -51,7 +51,7 @@ Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, um
|
||||
```julia
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π)
|
||||
end),0,2π,legend=false)
|
||||
```
|
||||
|
||||

|
||||
@@ -108,9 +108,9 @@ scatter!(rand(100); markersize=6,color=:blue)
|
||||
|
||||

|
||||
|
||||
### Suported line types
|
||||
### Line types
|
||||
|
||||
|
||||
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
|
||||
|
||||
```julia
|
||||
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
|
||||
@@ -122,9 +122,9 @@ plot(x,y; linetypes=types,labels=map(string,types))
|
||||
|
||||

|
||||
|
||||
### Supported line styles
|
||||
### Line styles
|
||||
|
||||
|
||||
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
|
||||
|
||||
```julia
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
@@ -133,13 +133,13 @@ plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
|
||||
|
||||

|
||||
|
||||
### Supported marker types
|
||||
### Marker types
|
||||
|
||||
|
||||
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
|
||||
|
||||
```julia
|
||||
markers = setdiff(supportedMarkers(),[:none,:auto])
|
||||
plot([fill(i,10) for i = 1:length(markers)]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,labels=map(string,markers),markersize=10)
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 199 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@@ -32,6 +32,8 @@ export
|
||||
hline!,
|
||||
vline,
|
||||
vline!,
|
||||
ohlc,
|
||||
ohlc!,
|
||||
|
||||
savepng,
|
||||
|
||||
@@ -76,6 +78,8 @@ hline(args...; kw...) = plot(args...; kw..., linetype = :hline)
|
||||
hline!(args...; kw...) = plot!(args...; kw..., linetype = :hline)
|
||||
vline(args...; kw...) = plot(args...; kw..., linetype = :vline)
|
||||
vline!(args...; kw...) = plot!(args...; kw..., linetype = :vline)
|
||||
ohlc(args...; kw...) = plot(args...; kw..., linetype = :ohlc)
|
||||
ohlc!(args...; kw...) = plot!(args...; kw..., linetype = :ohlc)
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
@@ -83,7 +87,7 @@ vline!(args...; kw...) = plot!(args...; kw..., linetype = :vline)
|
||||
|
||||
savepng(args...; kw...) = savepng(currentPlot(), args...; kw...)
|
||||
savepng(plt::PlottingObject, args...; kw...) = savepng(plt.plotter, plt, args...; kw...)
|
||||
savepng(::PlottingPackage, plt::PlottingObject, fn::String, args...) = error("unsupported") # fallback so multiple dispatch doesn't get confused if it's missing
|
||||
savepng(::PlottingPackage, plt::PlottingObject, fn::AbstractString, args...) = error("unsupported") # fallback so multiple dispatch doesn't get confused if it's missing
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# const COLORS = [:black, :blue, :green, :red, :darkGray, :darkCyan, :darkYellow, :darkMagenta,
|
||||
# :darkBlue, :darkGreen, :darkRed, :gray, :cyan, :yellow, :magenta]
|
||||
|
||||
const COLORS = distinguishable_colors(20)
|
||||
# const COLORS = distinguishable_colors(20)
|
||||
const AXES = [:left, :right]
|
||||
const TYPES = [:line,
|
||||
:step,
|
||||
@@ -16,9 +16,10 @@ const TYPES = [:line,
|
||||
:bar,
|
||||
:hline,
|
||||
:vline,
|
||||
:ohlc,
|
||||
]
|
||||
const STYLES = [:solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
const MARKERS = [:ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon]
|
||||
const MARKERS = [:ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon, :octagon]
|
||||
|
||||
const ALL_AXES = vcat(:auto, AXES)
|
||||
const ALL_TYPES = vcat(:none, TYPES)
|
||||
@@ -39,54 +40,53 @@ subplotSupported() = subplotSupported(plotter())
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
const PLOT_DEFAULTS = Dict{Symbol, Any}()
|
||||
const _seriesDefaults = Dict{Symbol, Any}()
|
||||
|
||||
# series-specific
|
||||
PLOT_DEFAULTS[:axis] = :left
|
||||
PLOT_DEFAULTS[:color] = :auto
|
||||
PLOT_DEFAULTS[:label] = "AUTO"
|
||||
PLOT_DEFAULTS[:width] = 1
|
||||
PLOT_DEFAULTS[:linetype] = :line
|
||||
PLOT_DEFAULTS[:linestyle] = :solid
|
||||
PLOT_DEFAULTS[:marker] = :none
|
||||
PLOT_DEFAULTS[:markercolor] = :match
|
||||
PLOT_DEFAULTS[:markersize] = 6
|
||||
PLOT_DEFAULTS[:nbins] = 100 # number of bins for heatmaps and hists
|
||||
PLOT_DEFAULTS[:heatmap_c] = (0.15, 0.5)
|
||||
PLOT_DEFAULTS[:fillto] = nothing # fills in the area
|
||||
PLOT_DEFAULTS[:reg] = false # regression line?
|
||||
_seriesDefaults[:axis] = :left
|
||||
_seriesDefaults[:color] = :auto
|
||||
_seriesDefaults[:label] = "AUTO"
|
||||
_seriesDefaults[:width] = 1
|
||||
_seriesDefaults[:linetype] = :line
|
||||
_seriesDefaults[:linestyle] = :solid
|
||||
_seriesDefaults[:marker] = :none
|
||||
_seriesDefaults[:markercolor] = :match
|
||||
_seriesDefaults[:markersize] = 6
|
||||
_seriesDefaults[:nbins] = 100 # number of bins for heatmaps and hists
|
||||
_seriesDefaults[:heatmap_c] = (0.15, 0.5)
|
||||
_seriesDefaults[:fillto] = nothing # fills in the area
|
||||
_seriesDefaults[:reg] = false # regression line?
|
||||
_seriesDefaults[:group] = nothing
|
||||
_seriesDefaults[:ribbon] = nothing
|
||||
_seriesDefaults[:args] = [] # additional args to pass to the backend
|
||||
_seriesDefaults[:kwargs] = [] # additional keyword args to pass to the backend
|
||||
# note: can be Vector{Dict} or Vector{Tuple}
|
||||
|
||||
|
||||
const _plotDefaults = Dict{Symbol, Any}()
|
||||
|
||||
# plot globals
|
||||
PLOT_DEFAULTS[:title] = ""
|
||||
PLOT_DEFAULTS[:xlabel] = ""
|
||||
PLOT_DEFAULTS[:ylabel] = ""
|
||||
PLOT_DEFAULTS[:yrightlabel] = ""
|
||||
PLOT_DEFAULTS[:legend] = true
|
||||
# PLOT_DEFAULTS[:background_color] = nothing
|
||||
# PLOT_DEFAULTS[:xticks] = true
|
||||
# PLOT_DEFAULTS[:yticks] = true
|
||||
PLOT_DEFAULTS[:size] = (600,400)
|
||||
PLOT_DEFAULTS[:windowtitle] = "Plots.jl"
|
||||
# PLOT_DEFAULTS[:show] = true
|
||||
_plotDefaults[:title] = ""
|
||||
_plotDefaults[:xlabel] = ""
|
||||
_plotDefaults[:ylabel] = ""
|
||||
_plotDefaults[:yrightlabel] = ""
|
||||
_plotDefaults[:legend] = true
|
||||
_plotDefaults[:background_color] = colorant"white"
|
||||
_plotDefaults[:xticks] = true
|
||||
_plotDefaults[:yticks] = true
|
||||
_plotDefaults[:size] = (600,400)
|
||||
_plotDefaults[:windowtitle] = "Plots.jl"
|
||||
_plotDefaults[:show] = false
|
||||
|
||||
|
||||
PLOT_DEFAULTS[:args] = [] # additional args to pass to the backend
|
||||
PLOT_DEFAULTS[:kwargs] = [] # additional keyword args to pass to the backend
|
||||
# note: can be Vector{Dict} or Vector{Tuple}
|
||||
|
||||
# TODO: x/y scales
|
||||
|
||||
const ARGS = sort(collect(keys(PLOT_DEFAULTS)))
|
||||
const ARGS = sort(collect(intersect(keys(_seriesDefaults), keys(_plotDefaults))))
|
||||
supportedArgs(::PlottingPackage) = ARGS
|
||||
supportedArgs() = supportedArgs(plotter())
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
plotDefault(sym::Symbol) = PLOT_DEFAULTS[sym]
|
||||
function plotDefault!(sym::Symbol, val)
|
||||
PLOT_DEFAULTS[sym] = val
|
||||
end
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
makeplural(s::Symbol) = Symbol(string(s,"s"))
|
||||
@@ -97,21 +97,140 @@ autopick(notarr, idx::Integer) = notarr
|
||||
autopick_ignore_none_auto(arr::AVec, idx::Integer) = autopick(setdiff(arr, [:none, :auto]), idx)
|
||||
autopick_ignore_none_auto(notarr, idx::Integer) = notarr
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Alternate args
|
||||
|
||||
const keyAliases = Dict(
|
||||
:c => :color,
|
||||
:l => :label,
|
||||
:w => :width,
|
||||
:linewidth => :width,
|
||||
:type => :linetype,
|
||||
:t => :linetype,
|
||||
:style => :linestyle,
|
||||
:s => :linestyle,
|
||||
:m => :marker,
|
||||
:mc => :markercolor,
|
||||
:mcolor => :markercolor,
|
||||
:ms => :markersize,
|
||||
:msize => :markersize,
|
||||
:nb => :nbins,
|
||||
:nbin => :nbins,
|
||||
:fill => :fillto,
|
||||
:g => :group,
|
||||
:r => :ribbon,
|
||||
:xlab => :xlabel,
|
||||
:ylab => :ylabel,
|
||||
:yrlab => :yrightlabel,
|
||||
:ylabr => :yrightlabel,
|
||||
:y2lab => :yrightlabel,
|
||||
:ylab2 => :yrightlabel,
|
||||
:ylabelright => :yrightlabel,
|
||||
:ylabel2 => :yrightlabel,
|
||||
:y2label => :yrightlabel,
|
||||
:leg => :legend,
|
||||
:bg => :background_color,
|
||||
:bgcolor => :background_color,
|
||||
:bg_color => :background_color,
|
||||
:background => :background_color,
|
||||
:windowsize => :size,
|
||||
:wsize => :size,
|
||||
:wtitle => :windowtitle,
|
||||
:display => :show,
|
||||
)
|
||||
|
||||
# add all pluralized forms to the keyAliases dict
|
||||
for arg in keys(_seriesDefaults)
|
||||
keyAliases[makeplural(arg)] = arg
|
||||
end
|
||||
|
||||
|
||||
function replaceAliases!(d::Dict)
|
||||
for (k,v) in d
|
||||
if haskey(keyAliases, k)
|
||||
d[keyAliases[k]] = v
|
||||
delete!(d, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# update the defaults globally
|
||||
|
||||
function plotDefault(k::Symbol)
|
||||
if haskey(_seriesDefaults, k)
|
||||
return _seriesDefaults[k]
|
||||
elseif haskey(_plotDefaults, k)
|
||||
return _plotDefaults[k]
|
||||
else
|
||||
error("Unknown key: ", k)
|
||||
end
|
||||
end
|
||||
|
||||
function plotDefault!(k::Symbol, v)
|
||||
if haskey(_seriesDefaults, k)
|
||||
_seriesDefaults[k] = v
|
||||
elseif haskey(_plotDefaults, k)
|
||||
_plotDefaults[k] = v
|
||||
else
|
||||
error("Unknown key: ", k)
|
||||
end
|
||||
end
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
convertColor(c::Union{AbstractString, Symbol}) = parse(Colorant, string(c))
|
||||
convertColor(c::Colorant) = c
|
||||
convertColor(cvec::AbstractVector) = map(convertColor, cvec)
|
||||
|
||||
isbackgrounddark(bgcolor::Color) = Lab(bgcolor).l < 0.5
|
||||
|
||||
# move closer to lighter/darker depending on background value
|
||||
function adjustAway(val, bgval, vmin=0., vmax=100.)
|
||||
if bgval < 0.5 * (vmax+vmin)
|
||||
tmp = max(val, bgval)
|
||||
return 0.5 * (tmp + max(tmp, vmax))
|
||||
else
|
||||
tmp = min(val, bgval)
|
||||
return 0.5 * (tmp + min(tmp, vmin))
|
||||
end
|
||||
end
|
||||
|
||||
function getBackgroundRGBColor(c, d::Dict)
|
||||
bgcolor = convertColor(d[:background_color])
|
||||
d[:background_color] = bgcolor
|
||||
palette = distinguishable_colors(20, bgcolor)[2:end]
|
||||
|
||||
# try to adjust lightness away from background color
|
||||
bg_lab = Lab(bgcolor)
|
||||
palette = RGB{Float64}[begin
|
||||
lab = Lab(rgb)
|
||||
Lab(
|
||||
adjustAway(lab.l, bg_lab.l, 25, 75),
|
||||
lab.a,
|
||||
lab.b
|
||||
)
|
||||
end for rgb in palette]
|
||||
d[:color_palette] = palette
|
||||
|
||||
# set the foreground color (text, ticks, gridlines) to be white or black depending
|
||||
# on how dark the background is. borrowed from http://stackoverflow.com/a/1855903
|
||||
a = 0.299 * red(bgcolor) + 0.587 * green(bgcolor) + 0.114 * blue(bgcolor)
|
||||
d[:foreground_color] = a < 0.5 ? colorant"white" : colorant"black"
|
||||
|
||||
bgcolor
|
||||
end
|
||||
|
||||
# converts a symbol or string into a colorant (Colors.RGB), and assigns a color automatically
|
||||
# note: if plt is nothing, we aren't doing anything with the color anyways
|
||||
function getRGBColor(c, n::Int = 0)
|
||||
function getSeriesRGBColor(c, d::Dict, n::Int)
|
||||
|
||||
# auto-assign a color based on plot index
|
||||
if c == :auto && n > 0
|
||||
c = autopick(COLORS, n)
|
||||
end
|
||||
|
||||
# convert it from a symbol/string
|
||||
if isa(c, Symbol)
|
||||
c = string(c)
|
||||
end
|
||||
if isa(c, String)
|
||||
c = parse(Colorant, c)
|
||||
if c == :auto
|
||||
c = autopick(d[:color_palette], n)
|
||||
else
|
||||
c = convertColor(c)
|
||||
end
|
||||
|
||||
# should be a RGB now... either it was passed in, generated automatically, or created from a string
|
||||
@@ -121,8 +240,7 @@ function getRGBColor(c, n::Int = 0)
|
||||
c
|
||||
end
|
||||
|
||||
# const ALT_ARG_NAMES = Dict{Tuple{Symbol,Symbol}, Any}()
|
||||
# ALT_ARG_NAMES[(:linetype, :scatter)] = :scatter
|
||||
|
||||
|
||||
function warnOnUnsupported(pkg::PlottingPackage, d::Dict)
|
||||
d[:axis] in supportedAxes(pkg) || warn("axis $(d[:axis]) is unsupported with $pkg. Choose from: $(supportedAxes(pkg))")
|
||||
@@ -132,93 +250,173 @@ function warnOnUnsupported(pkg::PlottingPackage, d::Dict)
|
||||
end
|
||||
|
||||
|
||||
# note: idx is the index of this series within this call, n is the index of the series from all calls to plot/subplot
|
||||
function getPlotKeywordArgs(pkg::PlottingPackage, kw, idx::Int, n::Int)
|
||||
function getPlotArgs(pkg::PlottingPackage, kw, idx::Int)
|
||||
d = Dict(kw)
|
||||
|
||||
# # replace alternate names
|
||||
# for tup in kw
|
||||
# if haskey(ALT_ARG_NAMES, tup)
|
||||
# d[tup[1]] = ALT_ARG_NAMES[tup]
|
||||
# end
|
||||
# end
|
||||
|
||||
# default to a white background, but only on the initial call (so we don't change the background automatically)
|
||||
if haskey(d, :background_color)
|
||||
d[:background_color] = getRGBColor(d[:background_color])
|
||||
elseif n == 0
|
||||
d[:background_color] = colorant"white"
|
||||
# add defaults?
|
||||
for k in keys(_plotDefaults)
|
||||
if haskey(d, k)
|
||||
v = d[k]
|
||||
if isa(v, AbstractVector) && !isempty(v)
|
||||
# we got a vector, cycling through
|
||||
d[k] = autopick(v, idx)
|
||||
end
|
||||
else
|
||||
d[k] = _plotDefaults[k]
|
||||
end
|
||||
end
|
||||
|
||||
# fill in d with either 1) plural value, 2) value, 3) default
|
||||
for k in keys(PLOT_DEFAULTS)
|
||||
plural = makeplural(k)
|
||||
if !haskey(d, k)
|
||||
if n == 0 || k != :size
|
||||
d[k] = haskey(d, plural) ? autopick(d[plural], idx) : PLOT_DEFAULTS[k]
|
||||
# convert color
|
||||
d[:background_color] = getBackgroundRGBColor(d[:background_color], d)
|
||||
|
||||
# no need for these
|
||||
delete!(d, :x)
|
||||
delete!(d, :y)
|
||||
|
||||
d
|
||||
end
|
||||
|
||||
|
||||
|
||||
# note: idx is the index of this series within this call, n is the index of the series from all calls to plot/subplot
|
||||
function getSeriesArgs(pkg::PlottingPackage, initargs::Dict, kw, idx::Int, n::Int) # TODO, pass in initargs, not plt
|
||||
d = Dict(kw)
|
||||
|
||||
# add defaults?
|
||||
for k in keys(_seriesDefaults)
|
||||
if haskey(d, k)
|
||||
v = d[k]
|
||||
if isa(v, AbstractVector) && !isempty(v)
|
||||
# we got a vector, cycling through
|
||||
d[k] = autopick(v, idx)
|
||||
end
|
||||
else
|
||||
d[k] = _seriesDefaults[k]
|
||||
end
|
||||
delete!(d, plural)
|
||||
end
|
||||
|
||||
# auto-pick
|
||||
if n > 0
|
||||
if d[:axis] == :auto
|
||||
d[:axis] = autopick_ignore_none_auto(supportedAxes(pkg), n)
|
||||
end
|
||||
# if d[:linetype] == :auto
|
||||
# d[:linetype] = autopick_ignore_none_auto(supportedTypes(pkg), n)
|
||||
# end
|
||||
if d[:linestyle] == :auto
|
||||
d[:linestyle] = autopick_ignore_none_auto(supportedStyles(pkg), n)
|
||||
end
|
||||
if d[:marker] == :auto
|
||||
d[:marker] = autopick_ignore_none_auto(supportedMarkers(pkg), n)
|
||||
end
|
||||
|
||||
if d[:axis] == :auto
|
||||
d[:axis] = autopick_ignore_none_auto(supportedAxes(pkg), n)
|
||||
end
|
||||
if d[:linestyle] == :auto
|
||||
d[:linestyle] = autopick_ignore_none_auto(supportedStyles(pkg), n)
|
||||
end
|
||||
if d[:marker] == :auto
|
||||
d[:marker] = autopick_ignore_none_auto(supportedMarkers(pkg), n)
|
||||
end
|
||||
|
||||
# # swap out dots for no line and a marker
|
||||
# if haskey(d, :linetype) && d[:linetype] == :scatter
|
||||
# d[:linetype] = :none
|
||||
# if d[:marker] == :none
|
||||
# d[:marker] = :ellipse
|
||||
# end
|
||||
# end
|
||||
# update color
|
||||
d[:color] = getSeriesRGBColor(d[:color], initargs, n)
|
||||
|
||||
# update markercolor
|
||||
mc = d[:markercolor]
|
||||
mc = (mc == :match ? d[:color] : getSeriesRGBColor(mc, initargs, n))
|
||||
d[:markercolor] = mc
|
||||
|
||||
|
||||
# handle plot initialization differently
|
||||
if n == 0
|
||||
delete!(d, :x)
|
||||
delete!(d, :y)
|
||||
else
|
||||
# once the plot is created, we can get line/marker colors
|
||||
|
||||
# update color
|
||||
d[:color] = getRGBColor(d[:color], n)
|
||||
|
||||
# update markercolor
|
||||
mc = d[:markercolor]
|
||||
mc = (mc == :match ? d[:color] : getRGBColor(mc, n))
|
||||
d[:markercolor] = mc
|
||||
|
||||
# set label
|
||||
label = d[:label]
|
||||
label = (label == "AUTO" ? "y_$n" : label)
|
||||
if d[:axis] == :right && length(label) >= 4 && label[end-3:end] != " (R)"
|
||||
label = string(label, " (R)")
|
||||
end
|
||||
d[:label] = label
|
||||
|
||||
warnOnUnsupported(pkg, d)
|
||||
# set label
|
||||
label = d[:label]
|
||||
label = (label == "AUTO" ? "y$n" : label)
|
||||
if d[:axis] == :right && length(label) >= 4 && label[end-3:end] != " (R)"
|
||||
label = string(label, " (R)")
|
||||
end
|
||||
d[:label] = label
|
||||
|
||||
warnOnUnsupported(pkg, d)
|
||||
|
||||
|
||||
d
|
||||
end
|
||||
|
||||
|
||||
|
||||
# # note: idx is the index of this series within this call, n is the index of the series from all calls to plot/subplot
|
||||
# function getPlotKeywordArgs(pkg::PlottingPackage, kw, idx::Int, n::Int)
|
||||
# d = Dict(kw)
|
||||
|
||||
# # # replace alternate names
|
||||
# # for tup in kw
|
||||
# # if haskey(ALT_ARG_NAMES, tup)
|
||||
# # d[tup[1]] = ALT_ARG_NAMES[tup]
|
||||
# # end
|
||||
# # end
|
||||
|
||||
# # default to a white background, but only on the initial call (so we don't change the background automatically)
|
||||
# if haskey(d, :background_color)
|
||||
# d[:background_color] = getRGBColor(d[:background_color])
|
||||
# elseif n == 0
|
||||
# d[:background_color] = colorant"white"
|
||||
# end
|
||||
|
||||
# # fill in d with either 1) plural value, 2) value, 3) default
|
||||
# for k in keys(PLOT_DEFAULTS)
|
||||
# plural = makeplural(k)
|
||||
# if !haskey(d, k)
|
||||
# if n == 0 || k != :size
|
||||
# d[k] = haskey(d, plural) ? autopick(d[plural], idx) : PLOT_DEFAULTS[k]
|
||||
# end
|
||||
# end
|
||||
# delete!(d, plural)
|
||||
# end
|
||||
|
||||
# # auto-pick
|
||||
# if n > 0
|
||||
# if d[:axis] == :auto
|
||||
# d[:axis] = autopick_ignore_none_auto(supportedAxes(pkg), n)
|
||||
# end
|
||||
# # if d[:linetype] == :auto
|
||||
# # d[:linetype] = autopick_ignore_none_auto(supportedTypes(pkg), n)
|
||||
# # end
|
||||
# if d[:linestyle] == :auto
|
||||
# d[:linestyle] = autopick_ignore_none_auto(supportedStyles(pkg), n)
|
||||
# end
|
||||
# if d[:marker] == :auto
|
||||
# d[:marker] = autopick_ignore_none_auto(supportedMarkers(pkg), n)
|
||||
# end
|
||||
|
||||
# end
|
||||
|
||||
# # # swap out dots for no line and a marker
|
||||
# # if haskey(d, :linetype) && d[:linetype] == :scatter
|
||||
# # d[:linetype] = :none
|
||||
# # if d[:marker] == :none
|
||||
# # d[:marker] = :ellipse
|
||||
# # end
|
||||
# # end
|
||||
|
||||
|
||||
|
||||
# # handle plot initialization differently
|
||||
# if n == 0
|
||||
# delete!(d, :x)
|
||||
# delete!(d, :y)
|
||||
# else
|
||||
# # once the plot is created, we can get line/marker colors
|
||||
|
||||
# # update color
|
||||
# d[:color] = getRGBColor(d[:color], n)
|
||||
|
||||
# # update markercolor
|
||||
# mc = d[:markercolor]
|
||||
# mc = (mc == :match ? d[:color] : getRGBColor(mc, n))
|
||||
# d[:markercolor] = mc
|
||||
|
||||
# # set label
|
||||
# label = d[:label]
|
||||
# label = (label == "AUTO" ? "y$n" : label)
|
||||
# if d[:axis] == :right && length(label) >= 4 && label[end-3:end] != " (R)"
|
||||
# label = string(label, " (R)")
|
||||
# end
|
||||
# d[:label] = label
|
||||
|
||||
# warnOnUnsupported(pkg, d)
|
||||
# end
|
||||
|
||||
|
||||
# d
|
||||
# end
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ gadfly!() = plotter!(:gadfly)
|
||||
|
||||
supportedArgs(::GadflyPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos])
|
||||
supportedAxes(::GadflyPackage) = setdiff(ALL_AXES, [:right])
|
||||
supportedTypes(::GadflyPackage) = [:none, :line, :step, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
||||
supportedStyles(::GadflyPackage) = [:auto, :solid]
|
||||
supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :cross]
|
||||
supportedTypes(::GadflyPackage) = [:none, :line, :step, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc]
|
||||
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||
supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon, :octagon]
|
||||
|
||||
|
||||
include("gadfly_shapes.jl")
|
||||
@@ -35,7 +35,7 @@ function createGadflyPlotObject(d::Dict)
|
||||
unshift!(gplt.guides, Gadfly.Guide.manual_color_key("", AbstractString[], Color[]))
|
||||
end
|
||||
|
||||
gplt.theme = Gadfly.Theme(background_color = (haskey(d, :background_color) ? d[:background_color] : colorant"white"))
|
||||
gplt.theme = Gadfly.Theme(background_color = d[:background_color])
|
||||
gplt
|
||||
end
|
||||
|
||||
@@ -45,102 +45,78 @@ function getLineGeoms(d::Dict)
|
||||
lt = d[:linetype]
|
||||
lt in (:heatmap,:hexbin) && return [Gadfly.Geom.hexbin(xbincount = d[:nbins], ybincount = d[:nbins])]
|
||||
lt == :hist && return [Gadfly.Geom.histogram(bincount = d[:nbins])]
|
||||
lt == :none && return [Gadfly.Geom.path]
|
||||
# lt == :none && return [Gadfly.Geom.path]
|
||||
lt == :line && return [Gadfly.Geom.path]
|
||||
lt == :scatter && return [Gadfly.Geom.point]
|
||||
lt == :bar && return [Gadfly.Geom.bar]
|
||||
lt == :step && return [Gadfly.Geom.step]
|
||||
|
||||
# NOTE: we won't actually show this (we'll set width to 0 later), but we need a geom so that Gadfly doesn't complain
|
||||
if lt in (:none, :ohlc)
|
||||
return [Gadfly.Geom.path]
|
||||
end
|
||||
|
||||
# lt == :sticks && return [Gadfly.Geom.bar]
|
||||
error("linetype $lt not currently supported with Gadfly")
|
||||
end
|
||||
|
||||
|
||||
# function createGadflyAnnotation(d::Dict)
|
||||
|
||||
# if d[:marker] == :rect
|
||||
# # get the width/height of the square (both are sz)
|
||||
# sz = d[:markersize] * Gadfly.px
|
||||
# halfsz = sz/2
|
||||
|
||||
# # remap x/y to the corner position of the squares
|
||||
# xs = map(z -> Gadfly.Compose.Measure(;cx=z) - halfsz, float(d[:x]))
|
||||
# ys = map(z -> Gadfly.Compose.Measure(;cy=z) + halfsz, float(d[:y]))
|
||||
|
||||
# # return an Annotation which will add those shapes to each point in the series
|
||||
# return Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), Gadfly.rectangle(xs,ys,[sz],[sz]), Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))
|
||||
|
||||
# else
|
||||
# # make circles
|
||||
# sz = 0.5 * d[:markersize] * Gadfly.px
|
||||
# xs = collect(float(d[:x]))
|
||||
# ys = collect(float(d[:y]))
|
||||
|
||||
# # return an Annotation which will add those shapes to each point in the series
|
||||
# return Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), Gadfly.circle(xs,ys,[sz]), Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))
|
||||
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
# serious hack (I think?) to draw my own shapes as annotations... will it work? who knows...
|
||||
function getMarkerGeomsAndGuides(d::Dict)
|
||||
marker = d[:marker]
|
||||
if marker == :none
|
||||
if marker == :none && d[:linetype] != :ohlc
|
||||
return [],[]
|
||||
end
|
||||
return [], [createGadflyAnnotation(d)]
|
||||
end
|
||||
|
||||
# # special handling for other marker shapes... gotta create Compose contexts and map them to series points using Guide.Annotation
|
||||
# elseif marker == :rect
|
||||
# # get the width/height of the square (both are sz)
|
||||
# sz = d[:markersize] * Gadfly.px
|
||||
# halfsz = sz/2
|
||||
|
||||
# # remap x/y to the corner position of the squares
|
||||
# xs = map(z -> Gadfly.Compose.Measure(;cx=z) - halfsz, float(d[:x]))
|
||||
# ys = map(z -> Gadfly.Compose.Measure(;cy=z) + halfsz, float(d[:y]))
|
||||
|
||||
# # return an Annotation which will add those shapes to each point in the series
|
||||
# return [], [Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), Gadfly.rectangle(xs,ys,[sz],[sz]), Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))]
|
||||
|
||||
# else
|
||||
# # make circles
|
||||
# sz = 0.5 * d[:markersize] * Gadfly.px
|
||||
# xs = collect(float(d[:x]))
|
||||
# ys = collect(float(d[:y]))
|
||||
|
||||
# # return an Annotation which will add those shapes to each point in the series
|
||||
# return [], [Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), Gadfly.circle(xs,ys,[sz]), Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))]
|
||||
|
||||
# end
|
||||
|
||||
# otherwise just return a Geom.point
|
||||
# [Gadfly.Geom.point], []
|
||||
# end
|
||||
|
||||
|
||||
function addGadflyFixedLines!(gplt, d::Dict)
|
||||
function addGadflyFixedLines!(gplt, d::Dict, theme)
|
||||
|
||||
sz = d[:width] * Gadfly.px
|
||||
c = d[:color]
|
||||
|
||||
if d[:linetype] == :hline
|
||||
geom = Gadfly.Geom.hline(color=c, size=sz)
|
||||
layer = Gadfly.layer(yintercept = d[:y], geom)
|
||||
layer = Gadfly.layer(yintercept = d[:y], geom, theme)
|
||||
else
|
||||
geom = Gadfly.Geom.vline(color=c, size=sz)
|
||||
layer = Gadfly.layer(xintercept = d[:y], geom)
|
||||
layer = Gadfly.layer(xintercept = d[:y], geom, theme)
|
||||
end
|
||||
|
||||
prepend!(gplt.layers, layer)
|
||||
end
|
||||
|
||||
|
||||
function getGadflyStrokeVector(linestyle::Symbol)
|
||||
dash = 12 * Compose.mm
|
||||
dot = 3 * Compose.mm
|
||||
gap = 2 * Compose.mm
|
||||
linestyle == :solid && return nothing
|
||||
linestyle == :dash && return [dash, gap]
|
||||
linestyle == :dot && return [dot, gap]
|
||||
linestyle == :dashdot && return [dash, gap, dot, gap]
|
||||
linestyle == :dashdotdot && return [dash, gap, dot, gap, dot, gap]
|
||||
error("unsupported linestyle: ", linestyle)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function addGadflySeries!(gplt, d::Dict)
|
||||
|
||||
gfargs = []
|
||||
|
||||
# set theme: color, line width, and point size
|
||||
line_width = d[:width] * (d[:linetype] == :none ? 0 : 1) * Gadfly.px # 0 width when we don't show a line
|
||||
line_style = getGadflyStrokeVector(d[:linestyle])
|
||||
theme = Gadfly.Theme(default_color = d[:color],
|
||||
line_width = line_width,
|
||||
default_point_size = 0.5 * d[:markersize] * Gadfly.px,
|
||||
line_style = line_style)
|
||||
push!(gfargs, theme)
|
||||
|
||||
# first things first... lets so the sticks hack
|
||||
if d[:linetype] == :sticks
|
||||
d, dScatter = sticksHack(;d...)
|
||||
@@ -151,11 +127,10 @@ function addGadflySeries!(gplt, d::Dict)
|
||||
end
|
||||
|
||||
elseif d[:linetype] in (:hline, :vline)
|
||||
addGadflyFixedLines!(gplt, d)
|
||||
addGadflyFixedLines!(gplt, d, theme)
|
||||
return
|
||||
end
|
||||
|
||||
gfargs = []
|
||||
end
|
||||
|
||||
# add the Geoms
|
||||
append!(gfargs, getLineGeoms(d))
|
||||
@@ -177,17 +152,6 @@ function addGadflySeries!(gplt, d::Dict)
|
||||
end
|
||||
|
||||
|
||||
# # if we haven't added any geoms, we're probably just going to use annotations?
|
||||
# isempty(gfargs) && return
|
||||
|
||||
|
||||
# set theme: color, line width, and point size
|
||||
line_width = d[:width] * (d[:linetype] == :none ? 0 : 1) * Gadfly.px # 0 width when we don't show a line
|
||||
theme = Gadfly.Theme(default_color = d[:color],
|
||||
line_width = line_width,
|
||||
default_point_size = 0.5 * d[:markersize] * Gadfly.px)
|
||||
push!(gfargs, theme)
|
||||
|
||||
# for histograms, set x=y
|
||||
x = d[d[:linetype] == :hist ? :y : :x]
|
||||
|
||||
@@ -226,7 +190,7 @@ end
|
||||
|
||||
# -------------------------------
|
||||
|
||||
function savepng(::GadflyPackage, plt::PlottingObject, fn::String;
|
||||
function savepng(::GadflyPackage, plt::PlottingObject, fn::AbstractString;
|
||||
w = 6 * Gadfly.inch,
|
||||
h = 4 * Gadfly.inch)
|
||||
o = getGadflyContext(plt.plotter, plt)
|
||||
|
||||
@@ -10,15 +10,42 @@ function createGadflyAnnotation(d::Dict)
|
||||
x, y = d[:x], d[:y]
|
||||
marker = d[:marker]
|
||||
|
||||
if marker == :rect
|
||||
if d[:linetype] == :ohlc
|
||||
shape = ohlcshape(x, y, d[:markersize])
|
||||
d[:y] = Float64[z[1] for z in y]
|
||||
d[:linetype] = :none
|
||||
return Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(nothing), Gadfly.stroke(d[:color])))
|
||||
|
||||
elseif marker == :rect
|
||||
shape = square(x, y, sz)
|
||||
|
||||
elseif marker == :diamond
|
||||
shape = diamond(x, y, sz)
|
||||
|
||||
elseif marker == :utriangle
|
||||
shape = utriangle(x, y, sz)
|
||||
|
||||
elseif marker == :dtriangle
|
||||
shape = utriangle(x, y, sz, -1)
|
||||
|
||||
elseif marker == :cross
|
||||
shape = cross(x, y, sz)
|
||||
|
||||
elseif marker == :xcross
|
||||
shape = xcross(x, y, sz)
|
||||
|
||||
elseif marker == :star1
|
||||
shape = star1(x, y, sz)
|
||||
|
||||
elseif marker == :star2
|
||||
shape = star2(x, y, sz)
|
||||
|
||||
elseif marker == :hexagon
|
||||
shape = hexagon(x, y, sz)
|
||||
|
||||
elseif marker == :octagon
|
||||
shape = octagon(x, y, sz)
|
||||
|
||||
else
|
||||
# make circles
|
||||
sz = 0.8 * d[:markersize] * Gadfly.px
|
||||
@@ -33,15 +60,14 @@ end
|
||||
|
||||
function square(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
|
||||
rect_xs = Vector{Compose.Measure}(n)
|
||||
rect_ys = Vector{Compose.Measure}(n)
|
||||
rect_ws = Vector{Compose.Measure}(n)
|
||||
s = 1/sqrt(2)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[1 + i % length(xs)])
|
||||
y = Compose.y_measure(ys[1 + i % length(ys)])
|
||||
r = rs[1 + i % length(rs)]
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
|
||||
rect_xs[i] = x - s*r
|
||||
rect_ys[i] = y + s*r
|
||||
@@ -54,12 +80,11 @@ end
|
||||
|
||||
function diamond(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[1 + i % length(xs)])
|
||||
y = Compose.y_measure(ys[1 + i % length(ys)])
|
||||
r = rs[1 + i % length(rs)]
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[(x, y - r), (x + r, y), (x, y + r), (x - r, y)]
|
||||
end
|
||||
|
||||
@@ -67,22 +92,183 @@ function diamond(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function cross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
s = 1/sqrt(5)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[1 + i % length(xs)])
|
||||
y = Compose.y_measure(ys[1 + i % length(ys)])
|
||||
r = rs[1 + i % length(rs)]
|
||||
u = s*r
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
u = 0.4r
|
||||
|
||||
# make a "plus sign"
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x, y - u), (x + u, y - 2u), (x + 2u, y - u),
|
||||
(x + u, y), (x + 2u, y + u), (x + u, y + 2u),
|
||||
(x, y + u), (x - u, y + 2u), (x - 2u, y + u),
|
||||
(x - u, y), (x - 2u, y - u), (x - u, y - 2u) ]
|
||||
(x-r, y-u), (x-r, y+u), # L edge
|
||||
(x-u, y+u), # BL inside
|
||||
(x-u, y+r), (x+u, y+r), # B edge
|
||||
(x+u, y+u), # BR inside
|
||||
(x+r, y+u), (x+r, y-u), # R edge
|
||||
(x+u, y-u), # TR inside
|
||||
(x+u, y-r), (x-u, y-r), # T edge
|
||||
(x-u, y-u) # TL inside
|
||||
]
|
||||
end
|
||||
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
function xcross(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
s = 1/sqrt(5)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
u = s*r
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x, y - u), (x + u, y - 2u), (x + 2u, y - u),
|
||||
(x + u, y), (x + 2u, y + u), (x + u, y + 2u),
|
||||
(x, y + u), (x - u, y + 2u), (x - 2u, y + u),
|
||||
(x - u, y), (x - 2u, y - u), (x - u, y - 2u)
|
||||
]
|
||||
end
|
||||
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
|
||||
function utriangle(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
s = 0.8
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
u = 0.8 * scalar * r
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x - r, y + u),
|
||||
(x + r, y + u),
|
||||
(x, y - u)
|
||||
]
|
||||
end
|
||||
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function star1(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
|
||||
# some magic scalars
|
||||
sx = 0.7
|
||||
sy1, sy2 = 1.2, 0.4
|
||||
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x-sx*r, y+r), # BL
|
||||
(x, y-sy1*r), # T
|
||||
(x+sx*r, y+r), # BR
|
||||
(x-r, y-sy2*r), # L
|
||||
(x+r, y-sy2*r) # R
|
||||
]
|
||||
end
|
||||
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function star2(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar = 1)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
u = 0.4r
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x-u, y), (x-r, y-r), # TL
|
||||
(x, y-u), (x+r, y-r), # TR
|
||||
(x+u, y), (x+r, y+r), # BR
|
||||
(x, y+u), (x-r, y+r) # BL
|
||||
]
|
||||
end
|
||||
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function hexagon(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
u = 0.6r
|
||||
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x-r, y-u), (x-r, y+u), # L edge
|
||||
(x, y+r), # B
|
||||
(x+r, y+u), (x+r, y-u), # R edge
|
||||
(x, y-r) # T
|
||||
]
|
||||
end
|
||||
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
|
||||
function octagon(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray)
|
||||
n = max(length(xs), length(ys), length(rs))
|
||||
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||
r = rs[mod1(i, length(rs))]
|
||||
u = 0.4r
|
||||
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x-r, y-u), (x-r, y+u), # L edge
|
||||
(x-u, y+r), (x+u, y+r), # B edge
|
||||
(x+r, y+u), (x+r, y-u), # R edge
|
||||
(x+u, y-r), (x-u, y-r), # T edge
|
||||
]
|
||||
end
|
||||
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
|
||||
# ---------------------------
|
||||
|
||||
function ohlcshape{T}(xs::AVec, ys::AVec{Tuple{T,T,T,T}}, tickwidth::Real)
|
||||
@assert length(xs) == length(ys)
|
||||
n = length(xs)
|
||||
u = tickwidth * Compose.px
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
for i in 1:n
|
||||
x = Compose.x_measure(xs[i])
|
||||
o,h,l,c = map(Compose.y_measure, ys[i])
|
||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||
(x, o), (x - u, o), (x, o), # open tick
|
||||
(x, l), (x, h), (x, c), # high/low bar
|
||||
(x + u, c), (x, c) # close tick
|
||||
]
|
||||
end
|
||||
return Gadfly.polygon(polys)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ end
|
||||
getGadflyContext(::ImmersePackage, plt::Plot) = plt.o[2]
|
||||
getGadflyContext(::ImmersePackage, subplt::Subplot) = buildGadflySubplotContext(subplt)
|
||||
|
||||
function savepng(::ImmersePackage, plt::PlottingObject, fn::String;
|
||||
function savepng(::ImmersePackage, plt::PlottingObject, fn::AbstractString;
|
||||
w = 6 * Immerse.inch,
|
||||
h = 4 * Immerse.inch)
|
||||
gctx = getGadflyContext(plt.plotter, plt)
|
||||
@@ -78,7 +78,7 @@ end
|
||||
function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
|
||||
|
||||
# create the Gtk window with vertical box vsep
|
||||
d = subplt.initargs
|
||||
d = subplt.initargs[1]
|
||||
w,h = d[:size]
|
||||
vsep = Gtk.GtkBoxLeaf(:v)
|
||||
win = Gtk.GtkWindowLeaf(vsep, d[:windowtitle], w, h)
|
||||
|
||||
@@ -11,8 +11,8 @@ pyplot!() = plotter!(:pyplot)
|
||||
supportedArgs(::PyPlotPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos])
|
||||
supportedAxes(::PyPlotPackage) = ALL_AXES
|
||||
supportedTypes(::PyPlotPackage) = [:none, :line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
||||
supportedStyles(::PyPlotPackage) = setdiff(ALL_STYLES, [:dashdotdot])
|
||||
supportedMarkers(::PyPlotPackage) = setdiff(ALL_MARKERS, [:star2])
|
||||
supportedStyles(::PyPlotPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||
supportedMarkers(::PyPlotPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :hexagon]
|
||||
subplotSupported(::PyPlotPackage) = false
|
||||
|
||||
# convert colorant to 4-tuple RGBA
|
||||
@@ -37,8 +37,8 @@ function getPyPlotMarker(marker::Symbol)
|
||||
marker == :diamond && return "D"
|
||||
marker == :utriangle && return "^"
|
||||
marker == :dtriangle && return "v"
|
||||
marker == :cross && return "x"
|
||||
marker == :xcross && return "+"
|
||||
marker == :cross && return "+"
|
||||
marker == :xcross && return "x"
|
||||
marker == :star1 && return "*"
|
||||
# marker == :star2 && return "*"
|
||||
marker == :hexagon && return "h"
|
||||
@@ -47,7 +47,7 @@ function getPyPlotMarker(marker::Symbol)
|
||||
end
|
||||
|
||||
# pass through
|
||||
function getPyPlotMarker(marker::String)
|
||||
function getPyPlotMarker(marker::AbstractString)
|
||||
@assert length(marker) == 1
|
||||
marker
|
||||
end
|
||||
@@ -122,9 +122,12 @@ function plot(pkg::PyPlotPackage; kw...)
|
||||
end
|
||||
|
||||
|
||||
function plot!(::PyPlotPackage, plt::Plot; kw...)
|
||||
function plot!(pkg::PyPlotPackage, plt::Plot; kw...)
|
||||
d = Dict(kw)
|
||||
|
||||
if !(d[:linetype] in supportedTypes(pkg))
|
||||
error("linetype $(d[:linetype]) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))")
|
||||
end
|
||||
|
||||
if d[:linetype] == :sticks
|
||||
d,_ = sticksHack(;d...)
|
||||
@@ -182,16 +185,12 @@ function plot!(::PyPlotPackage, plt::Plot; kw...)
|
||||
extraargs[:label] = d[:label]
|
||||
|
||||
# do the plot
|
||||
# @show lt
|
||||
if lt == :hist
|
||||
d[:serieshandle] = plotfunc(d[:y]; extraargs...)[1]
|
||||
elseif lt in (:scatter, :heatmap, :hexbin)
|
||||
d[:serieshandle] = plotfunc(d[:x], d[:y]; extraargs...)
|
||||
else
|
||||
d[:serieshandle] = plotfunc(d[:x], d[:y]; extraargs...)[1]
|
||||
# retval = plotfunc(d[:x], d[:y]; extraargs...)
|
||||
# @show retval
|
||||
# d[:serieshandle] = retval
|
||||
end
|
||||
|
||||
# this sets the bg color inside the grid (plt.o.o == matplotlib.Figure)
|
||||
@@ -223,7 +222,7 @@ end
|
||||
|
||||
# -------------------------------
|
||||
|
||||
function savepng(::PyPlotPackage, plt::PlottingObject, fn::String, args...)
|
||||
function savepng(::PyPlotPackage, plt::PlottingObject, fn::AbstractString, args...)
|
||||
addPyPlotLegend(plt)
|
||||
f = open(fn, "w")
|
||||
writemime(f, "image/png", plt.o)
|
||||
|
||||
@@ -12,13 +12,17 @@ supportedTypes(::QwtPackage) = [:none, :line, :step, :stepinverted, :sticks, :sc
|
||||
|
||||
function adjustQwtKeywords(iscreating::Bool; kw...)
|
||||
d = Dict(kw)
|
||||
d[:heatmap_n] = d[:nbins]
|
||||
if !iscreating
|
||||
d[:heatmap_n] = d[:nbins]
|
||||
end
|
||||
|
||||
if d[:linetype] == :hexbin
|
||||
d[:linetype] = :heatmap
|
||||
elseif d[:linetype] == :scatter
|
||||
d[:linetype] = :none
|
||||
d[:marker] = :ellipse
|
||||
if d[:marker] == :none
|
||||
d[:marker] = :ellipse
|
||||
end
|
||||
elseif !iscreating && d[:linetype] == :bar
|
||||
return barHack(; kw...)
|
||||
elseif !iscreating && d[:linetype] == :hist
|
||||
@@ -28,7 +32,8 @@ function adjustQwtKeywords(iscreating::Bool; kw...)
|
||||
end
|
||||
|
||||
function plot(pkg::QwtPackage; kw...)
|
||||
d = adjustQwtKeywords(true; kw...)
|
||||
d = Dict(kw)
|
||||
# d = adjustQwtKeywords(true; kw...)
|
||||
o = Qwt.plot(zeros(0,0); d..., show=false)
|
||||
plt = Plot(o, pkg, 0, d, Dict[])
|
||||
plt
|
||||
@@ -48,7 +53,7 @@ end
|
||||
|
||||
# -------------------------------
|
||||
|
||||
savepng(::QwtPackage, plt::PlottingObject, fn::String, args...) = Qwt.savepng(plt.o, fn)
|
||||
savepng(::QwtPackage, plt::PlottingObject, fn::AbstractString, args...) = Qwt.savepng(plt.o, fn)
|
||||
|
||||
# -------------------------------
|
||||
|
||||
@@ -61,7 +66,7 @@ function buildSubplotObject!(::QwtPackage, subplt::Subplot)
|
||||
i += rowcnt
|
||||
end
|
||||
subplt.o = Qwt.vsplitter(rows...)
|
||||
Qwt.resizewidget(subplt.o, subplt.initargs[:size]...)
|
||||
Qwt.resizewidget(subplt.o, subplt.initargs[1][:size]...)
|
||||
Qwt.moveToLastScreen(subplt.o) # hack so it goes to my center monitor... sorry
|
||||
end
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ end
|
||||
|
||||
# -------------------------------
|
||||
|
||||
function savepng(::[PkgName]Package, plt::PlottingObject, fn::String; kw...)
|
||||
function savepng(::[PkgName]Package, plt::PlottingObject, fn::AbstractString; kw...)
|
||||
# TODO: save a PNG of the underlying plot/subplot object
|
||||
end
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ function plot(pkg::UnicodePlotsPackage; kw...)
|
||||
plt = Plot(nothing, pkg, 0, Dict(kw), Dict[])
|
||||
|
||||
# do we want to give a new default size?
|
||||
if !haskey(plt.initargs, :size) || plt.initargs[:size] == PLOT_DEFAULTS[:size]
|
||||
if !haskey(plt.initargs, :size) || plt.initargs[:size] == _plotDefaults[:size]
|
||||
plt.initargs[:size] = (60,20)
|
||||
end
|
||||
|
||||
@@ -124,7 +124,7 @@ end
|
||||
|
||||
# -------------------------------
|
||||
|
||||
function savepng(::UnicodePlotsPackage, plt::PlottingObject, fn::String, args...)
|
||||
function savepng(::UnicodePlotsPackage, plt::PlottingObject, fn::AbstractString, args...)
|
||||
|
||||
# make some whitespace and show the plot
|
||||
println("\n\n\n\n\n\n")
|
||||
|
||||