Compare commits

...

13 Commits

Author SHA1 Message Date
Thomas Breloff ea7867429f added hline/vline support in gadfly 2015-09-17 10:14:13 -04:00
Thomas Breloff c5300cd7be notes 2015-09-17 08:32:32 -04:00
Thomas Breloff ea34c7d226 working on winston and examples 2015-09-16 17:17:05 -04:00
Thomas Breloff 537e04989f working on winston 2015-09-16 16:34:40 -04:00
Thomas Breloff d447c5dc25 moved exports into backend files 2015-09-16 15:11:44 -04:00
Thomas Breloff 73944fc9bf first draft winston 2015-09-16 15:08:50 -04:00
Thomas Breloff 01e994e0f1 regenerate markdown 2015-09-16 14:32:36 -04:00
Thomas Breloff af3f3f436c improving markdown 2015-09-16 14:24:58 -04:00
Thomas Breloff 56e90a266a examples 2015-09-16 14:16:58 -04:00
Thomas Breloff 1fc59ed522 fix ALL_ARGS; unicodeplots examples 2015-09-16 14:01:53 -04:00
Thomas Breloff 3a3b1a6c17 examples 2015-09-16 13:40:23 -04:00
Thomas Breloff 242ce807df examples 2015-09-16 13:32:43 -04:00
Thomas Breloff 734967152c fixed suppported typo 2015-09-16 13:29:51 -04:00
48 changed files with 648 additions and 74 deletions
+3 -1
View File
@@ -15,6 +15,7 @@ Please add wishlist items, bugs, or any other comments/questions to the issues l
- [UnicodePlots.jl](docs/unicodeplots_examples.md)
- [PyPlot.jl](docs/pyplot_examples.md)
- [Immerse.jl](docs/immerse_examples.md)
- [Winston.jl](docs/winston_examples.md)
## Installation
@@ -32,6 +33,7 @@ Pkg.add("Immerse")
Pkg.add("UnicodePlots")
Pkg.add("PyPlot") # requires python and matplotlib
Pkg.clone("https://github.com/tbreloff/Qwt.jl.git") # requires pyqt and pyqwt
Pkg.add("Winston")
```
## Use
@@ -255,7 +257,7 @@ plot(rand(100,2); colors = [:red, RGB(.5,.5,0)],
- [x] PyPlot.jl
- [x] UnicodePlots.jl
- [x] Qwt.jl
- [ ] Winston.jl
- [x] Winston.jl
- [ ] GLPlot.jl
- [ ] Bokeh.jl
- [ ] Vega.jl
+17 -6
View File
@@ -88,6 +88,12 @@ const examples = PlotExample[
]
function createStringOfMarkDownCodeValues(arr, prefix = "")
string("`", prefix, join(arr, "`, `$prefix"), "`")
end
createStringOfMarkDownSymbols(arr) = createStringOfMarkDownCodeValues(arr, ":")
function generate_markdown(pkgname::Symbol)
# set up the plotter, and don't show the plots by default
@@ -103,13 +109,15 @@ function generate_markdown(pkgname::Symbol)
md = open("$DOCDIR/$(pkgname)_examples.md", "w")
write(md, "# Examples for backend: $pkgname\n\n")
write(md, "- Supported arguments: $(join(supportedArgs(pkg), ", "))\n")
write(md, "- Supported values for axis: $(supportedAxes(pkg))\n")
write(md, "- Supported values for linetype: $(supportedTypes(pkg))\n")
write(md, "- Supported values for linestyle: $(supportedStyles(pkg))\n")
write(md, "- Supported values for marker: $(supportedMarkers(pkg))\n")
write(md, "- Supported arguments: $(createStringOfMarkDownCodeValues(supportedArgs(pkg)))\n")
write(md, "- Supported values for axis: $(createStringOfMarkDownSymbols(supportedAxes(pkg)))\n")
write(md, "- Supported values for linetype: $(createStringOfMarkDownSymbols(supportedTypes(pkg)))\n")
write(md, "- Supported values for linestyle: $(createStringOfMarkDownSymbols(supportedStyles(pkg)))\n")
write(md, "- Supported values for marker: $(createStringOfMarkDownSymbols(supportedMarkers(pkg)))\n")
write(md, "- Is `subplot`/`subplot!` supported? $(subplotSupported(pkg) ? "Yes" : "No")\n\n")
write(md, "### Initialize\n\n```julia\nusing Plots\n$(pkgname)!()\n```\n\n")
for (i,example) in enumerate(examples)
@@ -120,7 +128,9 @@ function generate_markdown(pkgname::Symbol)
# save the png
imgname = "$(pkgname)_example_$i.png"
savepng("$IMGDIR/$pkgname/$imgname")
# NOTE: uncomment this to overwrite the images as well
# savepng("$IMGDIR/$pkgname/$imgname")
# write out the header, description, code block, and image link
write(md, "### $(example.header)\n\n")
@@ -178,6 +188,7 @@ end
# generate_markdown(:gadfly)
# generate_markdown(:pyplot)
# generate_markdown(:immerse)
# generate_markdown(:winston)
end # module
+12 -5
View File
@@ -1,12 +1,19 @@
# Examples for backend: gadfly
- Supported arguments: args, axis, color, fillto, heatmap_c, 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 linestyle: [:auto,:solid]
- Supported values for marker: [:none,:auto,:rect,:ellipse,:diamond,:cross]
- 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 linestyle: `:auto`, `:solid`
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:cross`
- Is `subplot`/`subplot!` supported? Yes
### Initialize
```julia
using Plots
gadfly!()
```
### Lines
A simple line plot of the 3 columns.
+12 -5
View File
@@ -1,12 +1,19 @@
# Examples for backend: immerse
- Supported arguments: args, axis, color, fillto, heatmap_c, 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 linestyle: [:auto,:solid]
- Supported values for marker: [:none,:auto,:rect,:ellipse,:diamond,:cross]
- 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 linestyle: `:auto`, `:solid`
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:cross`
- Is `subplot`/`subplot!` supported? Yes
### Initialize
```julia
using Plots
immerse!()
```
### Lines
A simple line plot of the 3 columns.
+12 -5
View File
@@ -1,12 +1,19 @@
# Examples for backend: pyplot
- Supported arguments: args, axis, color, fillto, heatmap_c, kwargs, label, legend, linestyle, linetype, marker, markercolor, markersize, nbins, reg, size, title, width, windowtitle, xlabel, ylabel, yrightlabel
- 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 arguments: `args`, `axis`, `color`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `ylabel`, `yrightlabel`
- 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`
- Is `subplot`/`subplot!` supported? No
### Initialize
```julia
using Plots
pyplot!()
```
### Lines
A simple line plot of the 3 columns.
+12 -5
View File
@@ -1,12 +1,19 @@
# Examples for backend: qwt
- Supported arguments: args, axis, color, fillto, heatmap_c, kwargs, label, legend, linestyle, linetype, marker, markercolor, markersize, nbins, reg, size, title, width, windowtitle, xlabel, ylabel, yrightlabel
- 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,:dashdotdot]
- Supported values for marker: [:none,:auto,:ellipse,:rect,:diamond,:utriangle,:dtriangle,:cross,:xcross,:star1,:star2,:hexagon]
- Supported arguments: `args`, `axis`, `color`, `fillto`, `heatmap_c`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `reg`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `ylabel`, `yrightlabel`
- 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`, `:dashdotdot`
- Supported values for marker: `:none`, `:auto`, `:ellipse`, `:rect`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:star2`, `:hexagon`
- Is `subplot`/`subplot!` supported? Yes
### Initialize
```julia
using Plots
qwt!()
```
### Lines
A simple line plot of the 3 columns.
+45 -16
View File
@@ -1,3 +1,19 @@
# Examples for backend: unicodeplots
- Supported arguments: `args`, `axis`, `color`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `ylabel`, `yrightlabel`
- Supported values for axis: `:auto`, `:left`
- Supported values for linetype: `:none`, `:line`, `:step`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
- Supported values for linestyle: `:auto`, `:solid`
- Supported values for marker: `:none`, `:auto`, `:ellipse`
- Is `subplot`/`subplot!` supported? Yes
### Initialize
```julia
using Plots
unicodeplots!()
```
### Lines
A simple line plot of the 3 columns.
@@ -10,7 +26,7 @@ plot(rand(100,3))
### Functions
Plot multiple functions.
Plot multiple functions. You can also put the function first.
```julia
plot(0:0.01:4π,[sin,cos])
@@ -30,10 +46,10 @@ plot([sin,cos],0,4π)
###
Or make a parametric plot with plot(fx, fy, umin, umax).
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia
plot(sin,(x->begin # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
sin(2x)
end),0,2π)
```
@@ -54,7 +70,7 @@ plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RG
Use the `axis` or `axiss` arguments.
Note: This is only supported with Qwt right now
Note: Currently only supported with Qwt and PyPlot
```julia
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right],ylabel="LEFT",yrightlabel="RIGHT")
@@ -92,35 +108,48 @@ scatter!(rand(100); markersize=6,color=:blue)
![](../img/unicodeplots/unicodeplots_example_9.png)
### Lots of line types
### Heatmaps
Options: (:line, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
Note: some may not work with all backends
```julia
plot(rand(20,4); linetypes=[:line,:step,:sticks,:scatter],labels=["line","step","sticks","dots"])
heatmap(randn(10000),randn(10000); nbins=100)
```
![](../img/unicodeplots/unicodeplots_example_10.png)
### Suported line types
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
```julia
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
n = length(types)
x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n)
plot(x,y; linetypes=types,labels=map(string,types))
```
![](../img/unicodeplots/unicodeplots_example_11.png)
### Lots of line styles
### Supported line styles
Options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
Note: some may not work with all backends
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
```julia
plot(rand(20,5); linestyles=[:solid,:dash,:dot,:dashdot,:dashdotdot],labels=["solid","dash","dot","dashdot","dashdotdot"])
styles = setdiff(supportedStyles(),[:auto])
plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
```
![](../img/unicodeplots/unicodeplots_example_12.png)
### Lots of marker types
### Supported marker types
Options: (:none, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
Note: some may not work with all backends
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
```julia
plot(repmat(collect(1:10)',10,1); markers=[:ellipse,:rect,:diamond,:utriangle,:dtriangle,:cross,:xcross,:star1,:star2,:hexagon],labels=["ellipse","rect","diamond","utriangle","dtriangle","cross","xcross","star1","star2","hexagon"],markersize=10)
markers = setdiff(supportedMarkers(),[:none,:auto])
plot([fill(i,10) for i = 1:length(markers)]; marker=:auto,labels=map(string,markers),markersize=10)
```
![](../img/unicodeplots/unicodeplots_example_13.png)
+166
View File
@@ -0,0 +1,166 @@
# Examples for backend: winston
- 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`
- Is `subplot`/`subplot!` supported? No
### Initialize
```julia
using Plots
winston!()
```
### Lines
A simple line plot of the 3 columns.
```julia
plot(rand(100,3))
```
![](../img/winston/winston_example_1.png)
### Functions
Plot multiple functions. You can also put the function first.
```julia
plot(0:0.01:4π,[sin,cos])
```
![](../img/winston/winston_example_2.png)
###
You can also call it with plot(f, xmin, xmax).
```julia
plot([sin,cos],0,4π)
```
![](../img/winston/winston_example_3.png)
###
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
sin(2x)
end),0,2π)
```
![](../img/winston/winston_example_4.png)
### Global
Change the guides/background without a separate call.
```julia
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.5,0.5,0.5))
```
![](../img/winston/winston_example_5.png)
### Two-axis
Use the `axis` or `axiss` arguments.
Note: Currently only supported with Qwt and PyPlot
```julia
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right],ylabel="LEFT",yrightlabel="RIGHT")
```
![](../img/winston/winston_example_6.png)
### Vectors w/ pluralized args
Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`).
```julia
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue])
```
![](../img/winston/winston_example_7.png)
### Build plot in pieces
Start with a base plot...
```julia
plot(rand(100) / 3; reg=true,fillto=0)
```
![](../img/winston/winston_example_8.png)
###
and add to it later.
```julia
scatter!(rand(100); markersize=6,color=:blue)
```
![](../img/winston/winston_example_9.png)
### Suported line types
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
```julia
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
n = length(types)
x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n)
plot(x,y; linetypes=types,labels=map(string,types))
```
![](../img/winston/winston_example_11.png)
### Supported line styles
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
```julia
styles = setdiff(supportedStyles(),[:auto])
plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
```
![](../img/winston/winston_example_12.png)
### Supported 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)
```
![](../img/winston/winston_example_13.png)
### Bar
x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)
```julia
bar(randn(1000))
```
![](../img/winston/winston_example_14.png)
### Histogram
note: fillto isn't supported on all backends
```julia
histogram(randn(1000); nbins=50,fillto=20)
```
![](../img/winston/winston_example_15.png)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

+17 -16
View File
@@ -6,39 +6,36 @@ using Colors
export
plotter,
plot,
plot_display,
subplot,
plotter!,
plot,
plot!,
plot_display,
plot_display!,
subplot,
subplot!,
currentPlot,
plotDefault,
scatter,
bar,
histogram,
heatmap,
sticks,
currentPlot!,
plotDefault,
plotDefault!,
scatter,
scatter!,
bar,
bar!,
histogram,
histogram!,
heatmap,
heatmap!,
sticks,
sticks!,
hline,
hline!,
vline,
vline!,
savepng,
backends,
qwt!,
gadfly!,
unicodeplots!,
pyplot!,
immerse!,
supportedArgs,
supportedAxes,
@@ -75,6 +72,10 @@ heatmap(args...; kw...) = plot(args...; kw..., linetype = :heatmap)
heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap)
sticks(args...; kw...) = plot(args...; kw..., linetype = :sticks, marker = :ellipse)
sticks!(args...; kw...) = plot!(args...; kw..., linetype = :sticks, marker = :ellipse)
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)
# ---------------------------------------------------------
+18 -1
View File
@@ -5,7 +5,18 @@
const COLORS = distinguishable_colors(20)
const AXES = [:left, :right]
const TYPES = [:line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
const TYPES = [:line,
:step,
:stepinverted,
:sticks,
:scatter,
:heatmap,
:hexbin,
:hist,
:bar,
:hline,
:vline,
]
const STYLES = [:solid, :dash, :dot, :dashdot, :dashdotdot]
const MARKERS = [:ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon]
@@ -207,3 +218,9 @@ function getPlotKeywordArgs(pkg::PlottingPackage, kw, idx::Int, n::Int)
d
end
# -----------------------------------------------------------------------------
# TODO: arg aliases
+26 -2
View File
@@ -3,12 +3,13 @@
immutable GadflyPackage <: PlottingPackage end
export gadfly!
gadfly!() = plotter!(:gadfly)
suppportedArgs(::GadflyPackage) = setdiff(ALL_ARGS, [:heatmap_c, :fillto, :pos])
supportedArgs(::GadflyPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos])
supportedAxes(::GadflyPackage) = setdiff(ALL_AXES, [:right])
supportedTypes(::GadflyPackage) = setdiff(TYPES, [:stepinverted])
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]
@@ -119,6 +120,25 @@ end
# end
function addGadflyFixedLines!(gplt, d::Dict)
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)
else
geom = Gadfly.Geom.vline(color=c, size=sz)
layer = Gadfly.layer(xintercept = d[:y], geom)
end
prepend!(gplt.layers, layer)
end
function addGadflySeries!(gplt, d::Dict)
# first things first... lets so the sticks hack
@@ -129,6 +149,10 @@ function addGadflySeries!(gplt, d::Dict)
if dScatter[:marker] != :none
push!(gplt.guides, createGadflyAnnotation(dScatter))
end
elseif d[:linetype] in (:hline, :vline)
addGadflyFixedLines!(gplt, d)
return
end
gfargs = []
+2 -1
View File
@@ -3,10 +3,11 @@
immutable ImmersePackage <: PlottingPackage end
export immerse!
immerse!() = plotter!(:immerse)
suppportedArgs(::ImmersePackage) = suppportedArgs(GadflyPackage())
supportedArgs(::ImmersePackage) = supportedArgs(GadflyPackage())
supportedAxes(::ImmersePackage) = supportedAxes(GadflyPackage())
supportedTypes(::ImmersePackage) = supportedTypes(GadflyPackage())
supportedStyles(::ImmersePackage) = supportedStyles(GadflyPackage())
+4 -3
View File
@@ -3,13 +3,14 @@
immutable PyPlotPackage <: PlottingPackage end
export pyplot!
pyplot!() = plotter!(:pyplot)
# -------------------------------
suppportedArgs(::PyPlotPackage) = setdiff(ALL_ARGS, [:reg, :heatmap_c, :fillto, :pos])
# supportedAxes(::PyPlotPackage) = [:left]
# supportedTypes(::PyPlotPackage) = setdiff(TYPES, [:stepinverted])
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])
subplotSupported(::PyPlotPackage) = false
+3
View File
@@ -3,8 +3,11 @@
immutable QwtPackage <: PlottingPackage end
export qwt!
qwt!() = plotter!(:qwt)
supportedTypes(::QwtPackage) = [:none, :line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
# -------------------------------
function adjustQwtKeywords(iscreating::Bool; kw...)
+5 -4
View File
@@ -5,15 +5,16 @@
immutable [PkgName]Package <: PlottingPackage end
export [pkgname]!
[pkgname]!() = plotter!(:[pkgname])
# ---------------------------------------------------------------------------
supportedArgs(::[PkgName]Package) = ARGS
supportedAxes(::[PkgName]Package) = AXES
supportedTypes(::[PkgName]Package) = TYPES
supportedStyles(::[PkgName]Package) = STYLES
supportedMarkers(::[PkgName]Package) = MARKERS
supportedAxes(::[PkgName]Package) = ALL_AXES
supportedTypes(::[PkgName]Package) = ALL_TYPES
supportedStyles(::[PkgName]Package) = ALL_STYLES
supportedMarkers(::[PkgName]Package) = ALL_MARKERS
subplotSupported(::[PkgName]Package) = false
# ---------------------------------------------------------------------------
+3 -2
View File
@@ -3,13 +3,14 @@
immutable UnicodePlotsPackage <: PlottingPackage end
export unicodeplots!
unicodeplots!() = plotter!(:unicodeplots)
# -------------------------------
suppportedArgs(::UnicodePlotsPackage) = setdiff(ALL_ARGS, [:reg, :heatmap_c, :fillto, :pos])
supportedArgs(::UnicodePlotsPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos])
supportedAxes(::UnicodePlotsPackage) = [:auto, :left]
supportedTypes(::UnicodePlotsPackage) = setdiff(ALL_TYPES, [:stepinverted])
supportedTypes(::UnicodePlotsPackage) = [:none, :line, :step, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
supportedMarkers(::UnicodePlotsPackage) = [:none, :auto, :ellipse]
+254
View File
@@ -0,0 +1,254 @@
# https://github.com/nolta/Winston.jl
# credit goes to https://github.com/jverzani for contributing to the first draft of this backend implementation
immutable WinstonPackage <: PlottingPackage end
export winston!
winston!() = plotter!(:winston)
# ---------------------------------------------------------------------------
## dictionaries for conversion of Plots.jl names to Winston ones.
const winston_linestyle = Dict(:solid=>"solid",
:dash=>"dash",
:dot=>"dotted",
:dashdot=>"dotdashed",
:dashdotdot=>"dotdashed")
const winston_marker = Dict(:none=>".",
:ellipse=>"circle",
:rect => "square",
:diamond=>"diamond",
:utriangle=>"triangle",
:dtriangle=>"down-triangle",
:cross => "cross",
:xcross => "cross",
:star1 => "asterisk",
:star2 => "filled circle",
:hexagon => "asterisk"
)
supportedArgs(::WinstonPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos, :markercolor, :background_color])
supportedAxes(::WinstonPackage) = [:auto, :left]
supportedTypes(::WinstonPackage) = [:none, :line, :sticks, :scatter, :hist, :bar]
supportedStyles(::WinstonPackage) = unshift!(collect(keys(winston_linestyle)), :auto) # vcat(:auto, keys(winston_linestyle))
supportedMarkers(::WinstonPackage) = unshift!(collect(keys(winston_marker)), :auto) # vcat(:auto, collect(keys(winston_marker)))
subplotSupported(::WinstonPackage) = false
# ---------------------------------------------------------------------------
# function createWinstonFigure(d::Dict)
# # println("Creating immerse figure: ", d)
# w,h = d[:size]
# figidx = Winston.figure(; name = d[:windowtitle], width = w, height = h)
# Winston.Figure(figidx)
# end
function plot(pkg::WinstonPackage; kw...)
d = Dict(kw)
# bgcolor
# create a new window
# the call to figure does a few things here:
# get a new unique id
# create a new GtkWindow (or Tk?)
# w,h = d[:size]
# canvas = Gtk.GtkCanvasLeaf()
# window = Gtk.GtkWindowLeaf(canvas, d[:windowtitle], w, h)
# figidx = Winston.figure(; name = d[:windowtitle], width = w, height = h)
# # skip the current fig stuff... just grab the fig directly
# fig = Winston._display.figs[figidx]
# overwrite the placeholder FramedPlot with our own
# fig.plot = Winston.FramedPlot(title = d[:title], xlabel = d[:xlabel], ylabel = d[:ylabel])
wplt = Winston.FramedPlot(title = d[:title], xlabel = d[:xlabel], ylabel = d[:ylabel])
# # using the figure index returned from Winston.figure, make this plot current and get the
# # Figure object (fields: window::GtkWindow and plot::FramedPlot)
# Winston.switchfig(Winston._display, figidx)
# fig = Winston.curfig(Winston._display)
# Winston._pwinston = fig.plot
# Winston.setattr(fig.plot, "xlabel", d[:xlabel])
# Winston.setattr(fig.plot, "ylabel", d[:ylabel])
# Winston.setattr(fig.plot, "title", d[:title])
Plot(wplt, pkg, 0, d, Dict[])
# Plot((window, canvas, wplt), pkg, 0, d, Dict[])
# Plot((fig, figidx), pkg, 0, d, Dict[])
end
copy_remove(d::Dict, s::Symbol) = delete!(copy(d), s)
function addRegressionLineWinston(d::Dict, wplt)
xs, ys = regressionXY(d[:x], d[:y])
Winston.add(wplt, Winston.Curve(xs, ys, kind="dotted"))
end
function getWinstonItems(plt::Plot)
if isa(plt.o, Winston.FramedPlot)
wplt = plt.o
window, canvas = nothing, nothing
else
window, canvas, wplt = plt.o
end
window, canvas, wplt
end
function plot!(::WinstonPackage, plt::Plot; kw...)
d = Dict(kw)
# # make this figure current
# fig, figidx = plt.o
# Winston.switchfig(Winston._display, figidx)
window, canvas, wplt = getWinstonItems(plt)
# until we call it normally, do the hack
if d[:linetype] == :bar
d = barHack(;d...)
end
e = Dict()
e[:color] = d[:color]
e[:linewidth] = d[:width]
e[:kind] = winston_linestyle[d[:linestyle]]
e[:symbolkind] = winston_marker[d[:marker]]
# markercolor # same choices as `color`, or :match will set the color to be the same as `color`
e[:symbolsize] = d[:markersize] / 5
# fillto # fillto value for area plots
# pos # (Int,Int), move the enclosing window to this position
# screen # Integer, move enclosing window to this screen number (for multiscreen desktops)
## lintype :line, :step, :stepinverted, :sticks, :dots, :none, :heatmap, :hexbin, :hist, :bar
if d[:linetype] == :none
Winston.add(wplt, Winston.Points(d[:x], d[:y]; copy_remove(e, :kind)...))
elseif d[:linetype] == :line
Winston.add(wplt, Winston.Curve(d[:x], d[:y]; e...))
elseif d[:linetype] == :scatter
if d[:marker] == :none
d[:marker] = :ellipse
end
# elseif d[:linetype] == :step
# fn = Winston.XXX
# elseif d[:linetype] == :stepinverted
# fn = Winston.XXX
elseif d[:linetype] == :sticks
Winston.add(wplt, Winston.Stems(d[:x], d[:y]; e...))
# elseif d[:linetype] == :dots
# fn = Winston.XXX
# elseif d[:linetype] == :heatmap
# fn = Winston.XXX
# elseif d[:linetype] == :hexbin
# fn = Winston.XXX
elseif d[:linetype] == :hist
hst = hist(d[:y], d[:nbins])
Winston.add(wplt, Winston.Histogram(hst...; copy_remove(e, :nbins)...))
# elseif d[:linetype] == :bar
# # fn = Winston.XXX
else
error("linetype $(d[:linetype]) not supported by Winston.")
end
# marker
if d[:marker] != :none
Winston.add(wplt, Winston.Points(d[:x], d[:y]; copy_remove(e, :kind)...))
end
# optionally add a regression line
d[:reg] && d[:linetype] != :hist && addRegressionLineWinston(d, wplt)
push!(plt.seriesargs, d)
plt
end
function addWinstonLegend(plt::Plot, wplt)
Winston.legend(wplt, [sd[:label] for sd in plt.seriesargs])
end
function Base.display(::WinstonPackage, plt::Plot)
# recreate the legend
# fig, figidx = plt.o
window, canvas, wplt = getWinstonItems(plt)
if window == nothing
# initialize window
w,h = plt.initargs[:size]
canvas = Gtk.GtkCanvasLeaf()
window = Gtk.GtkWindowLeaf(canvas, plt.initargs[:windowtitle], w, h)
# wplt = plt.o
plt.o = (window, canvas, wplt)
# else
# window, canvas, wplt = plt.o
end
addWinstonLegend(plt, wplt)
Winston.display(canvas, wplt)
Gtk.showall(window)
# # display the Figure
# display(fig)
# display(plt.o.window)
# # show it
# Winston.display(plt.o.plot)
end
# -------------------------------
function savepng(::WinstonPackage, plt::PlottingObject, fn::String; kw...)
f = open(fn, "w")
window, canvas, wplt = getWinstonItems(plt)
addWinstonLegend(plt, wplt)
writemime(f, "image/png", wplt)
close(f)
end
# -------------------------------
function buildSubplotObject!(::WinstonPackage, subplt::Subplot)
# TODO: build the underlying Subplot object. this is where you might layout the panes within a GUI window, for example
end
function Base.display(::WinstonPackage, subplt::Subplot)
# TODO: display/show the Subplot object
end
+6
View File
@@ -112,6 +112,12 @@ end
# this adds to a specific plot... most plot commands will flow through here
function plot!(plt::Plot, args...; kw...)
# TODO: handle a "group by" mechanism.
# will probably want to check for the :group kw param, and split into
# index partitions/filters to be passed through to the next step.
# Ideally we don't change the insides ot createKWargsList too much to
# save from code repetition. We could consider adding a throw
kwList = createKWargsList(plt, args...; kw...)
for (i,d) in enumerate(kwList)
plt.n += 1
+18 -2
View File
@@ -5,6 +5,7 @@ include("backends/gadfly.jl")
include("backends/unicodeplots.jl")
include("backends/pyplot.jl")
include("backends/immerse.jl")
include("backends/winston.jl")
# ---------------------------------------------------------
@@ -21,7 +22,7 @@ Base.display(pkg::PlottingPackage, subplt::Subplot) = error("display($pkg, subpl
# ---------------------------------------------------------
const BACKENDS = [:qwt, :gadfly, :unicodeplots, :pyplot, :immerse]
const BACKENDS = [:qwt, :gadfly, :unicodeplots, :pyplot, :immerse, :winston]
const INITIALIZED_BACKENDS = Set{Symbol}()
backends() = BACKENDS
@@ -32,6 +33,7 @@ function backend(sym::Symbol)
sym == :unicodeplots && return UnicodePlotsPackage()
sym == :pyplot && return PyPlotPackage()
sym == :immerse && return ImmersePackage()
sym == :winston && return WinstonPackage()
error("Unsupported backend $sym")
end
@@ -65,6 +67,10 @@ function pickDefaultBackend()
Pkg.installed("UnicodePlots")
return CurrentBackend(:unicodeplots)
end
try
Pkg.installed("Winston")
return CurrentBackend(:winston)
end
warn("You don't have any of the supported backends installed! Chose from ", backends())
return CurrentBackend(:gadfly)
end
@@ -124,11 +130,19 @@ function plotter()
error("Couldn't import Immerse. Install it with: Pkg.add(\"Immerse\")")
end
elseif currentBackendSymbol == :winston
try
@eval import Winston, Gtk
@eval export Winston, Gtk
catch
error("Couldn't import Winston. Install it with: Pkg.add(\"Winston\")")
end
else
error("Unknown plotter $currentBackendSymbol. Choose from: $BACKENDS")
end
push!(INITIALIZED_BACKENDS, currentBackendSymbol)
println("[Plots.jl] done.")
# println("[Plots.jl] done.")
end
CURRENT_BACKEND.pkg
@@ -150,6 +164,8 @@ function plotter!(modname)
CURRENT_BACKEND.pkg = PyPlotPackage()
elseif modname == :immerse
CURRENT_BACKEND.pkg = ImmersePackage()
elseif modname == :winston
CURRENT_BACKEND.pkg = WinstonPackage()
else
error("Unknown plotter $modname. Choose from: $BACKENDS")
end
+13
View File
@@ -105,6 +105,19 @@ function sticksHack(; kw...)
end
function regressionXY(x, y)
# regress
β, α = [x ones(length(x))] \ y
# make a line segment
regx = [minimum(x), maximum(x)]
regy = β * regx + α
regx, regy
end
# Some conversion functions
# note: I borrowed these conversion constants from Compose.jl's Measure
const INCH_SCALAR = 25.4