fixes, gadfly star shape, readme example
This commit is contained in:
parent
dbc90c9417
commit
2fe21b8547
20
README.md
20
README.md
@ -51,21 +51,20 @@ Plots will try to figure out a good default backend for you automatically based
|
|||||||
using Plots
|
using Plots
|
||||||
```
|
```
|
||||||
|
|
||||||
Do a plot in Gadfly, then save a png:
|
Do a plot in Gadfly (inspired by [this example](http://gadflyjl.org/geom_point.html)), then save a png:
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
# switch to Gadfly as a backend
|
gadfly!() # switch to Gadfly as a backend
|
||||||
gadfly!()
|
dataframes!() # turn on support for DataFrames inputs
|
||||||
|
|
||||||
|
# load some data
|
||||||
|
using RDatasets
|
||||||
|
iris = dataset("datasets", "iris");
|
||||||
|
|
||||||
# This will bring up a browser window with the plot. Add a semicolon at the end to skip display.
|
# This will bring up a browser window with the plot. Add a semicolon at the end to skip display.
|
||||||
plot(rand(10,2); marker = :rect, markersize = [10,30], style = :auto)
|
scatter(iris, :SepalLength, :SepalWidth, group=:Species, ms=12, m=[:+,:d,:s])
|
||||||
|
|
||||||
# save it as a PNG
|
|
||||||
savepng(Plots.IMG_DIR * "gadfly1.png")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
which saves:
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
See the examples pages for lots of examples of plots, and what those commands produce for each supported backend.
|
See the examples pages for lots of examples of plots, and what those commands produce for each supported backend.
|
||||||
@ -195,7 +194,7 @@ Keyword | Default | Type | Aliases
|
|||||||
`:background_color` | `RGB{U8}(1.0,1.0,1.0)` | Plot | `:background`, `:bg`, `:bg_color`, `:bgcolor`
|
`:background_color` | `RGB{U8}(1.0,1.0,1.0)` | Plot | `:background`, `:bg`, `:bg_color`, `:bgcolor`
|
||||||
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
|
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
|
||||||
`:legend` | `true` | Plot | `:leg`
|
`:legend` | `true` | Plot | `:leg`
|
||||||
`:show` | `false` | Plot | `:display`
|
`:show` | `false` | Plot | `:display`, `:gui`
|
||||||
`:size` | `(800,600)` | Plot | `:windowsize`, `:wsize`
|
`:size` | `(800,600)` | Plot | `:windowsize`, `:wsize`
|
||||||
`:title` | `` | Plot |
|
`:title` | `` | Plot |
|
||||||
`:windowtitle` | `Plots.jl` | Plot | `:wtitle`
|
`:windowtitle` | `Plots.jl` | Plot | `:wtitle`
|
||||||
@ -278,6 +277,7 @@ __Tip__: Call `gui()` to display the plot in a window. Interactivity depends on
|
|||||||
|
|
||||||
- [x] Plot vectors/matrices/functions
|
- [x] Plot vectors/matrices/functions
|
||||||
- [x] Plot DataFrames
|
- [x] Plot DataFrames
|
||||||
|
- [x] Grouping
|
||||||
- [ ] Scales
|
- [ ] Scales
|
||||||
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
|
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
|
||||||
- [ ] Custom markers
|
- [ ] Custom markers
|
||||||
|
|||||||
@ -51,21 +51,20 @@ Plots will try to figure out a good default backend for you automatically based
|
|||||||
using Plots
|
using Plots
|
||||||
```
|
```
|
||||||
|
|
||||||
Do a plot in Gadfly, then save a png:
|
Do a plot in Gadfly (inspired by [this example](http://gadflyjl.org/geom_point.html)), then save a png:
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
# switch to Gadfly as a backend
|
gadfly!() # switch to Gadfly as a backend
|
||||||
gadfly!()
|
dataframes!() # turn on support for DataFrames inputs
|
||||||
|
|
||||||
|
# load some data
|
||||||
|
using RDatasets
|
||||||
|
iris = dataset("datasets", "iris");
|
||||||
|
|
||||||
# This will bring up a browser window with the plot. Add a semicolon at the end to skip display.
|
# This will bring up a browser window with the plot. Add a semicolon at the end to skip display.
|
||||||
plot(rand(10,2); marker = :rect, markersize = [10,30], style = :auto)
|
scatter(iris, :SepalLength, :SepalWidth, group=:Species, ms=12, m=[:+,:d,:s])
|
||||||
|
|
||||||
# save it as a PNG
|
|
||||||
savepng(Plots.IMG_DIR * "gadfly1.png")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
which saves:
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
See the examples pages for lots of examples of plots, and what those commands produce for each supported backend.
|
See the examples pages for lots of examples of plots, and what those commands produce for each supported backend.
|
||||||
@ -206,6 +205,7 @@ __Tip__: Call `gui()` to display the plot in a window. Interactivity depends on
|
|||||||
|
|
||||||
- [x] Plot vectors/matrices/functions
|
- [x] Plot vectors/matrices/functions
|
||||||
- [x] Plot DataFrames
|
- [x] Plot DataFrames
|
||||||
|
- [x] Grouping
|
||||||
- [ ] Scales
|
- [ ] Scales
|
||||||
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
|
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
|
||||||
- [ ] Custom markers
|
- [ ] Custom markers
|
||||||
|
|||||||
1624
examples/iris.ipynb
1624
examples/iris.ipynb
File diff suppressed because one or more lines are too long
BIN
img/gadfly1.png
BIN
img/gadfly1.png
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 56 KiB |
@ -47,12 +47,12 @@ function getLineGeoms(d::Dict)
|
|||||||
lt == :hist && return [Gadfly.Geom.histogram(bincount = d[:nbins])]
|
lt == :hist && return [Gadfly.Geom.histogram(bincount = d[:nbins])]
|
||||||
# lt == :none && return [Gadfly.Geom.path]
|
# lt == :none && return [Gadfly.Geom.path]
|
||||||
lt == :path && return [Gadfly.Geom.path]
|
lt == :path && return [Gadfly.Geom.path]
|
||||||
lt == :scatter && return [Gadfly.Geom.point]
|
# lt == :scatter && return [Gadfly.Geom.point]
|
||||||
lt == :bar && return [Gadfly.Geom.bar]
|
lt == :bar && return [Gadfly.Geom.bar]
|
||||||
lt == :steppost && return [Gadfly.Geom.step]
|
lt == :steppost && 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
|
# 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)
|
if lt in (:none, :ohlc, :scatter)
|
||||||
return [Gadfly.Geom.path]
|
return [Gadfly.Geom.path]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
|||||||
# line_style = getGadflyStrokeVector(d[:linestyle])
|
# line_style = getGadflyStrokeVector(d[:linestyle])
|
||||||
|
|
||||||
# set theme: color, line width, and point size
|
# set theme: color, line width, and point size
|
||||||
line_width = d[:width] * (d[:linetype] in (:none, :ohlc) ? 0 : 1) * Gadfly.px # 0 width when we don't show a line
|
line_width = d[:width] * (d[:linetype] in (:none, :ohlc, :scatter) ? 0 : 1) * Gadfly.px # 0 width when we don't show a line
|
||||||
# fg = initargs[:foreground_color]
|
# fg = initargs[:foreground_color]
|
||||||
theme = Gadfly.Theme(; default_color = d[:color],
|
theme = Gadfly.Theme(; default_color = d[:color],
|
||||||
line_width = line_width,
|
line_width = line_width,
|
||||||
@ -149,6 +149,13 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if d[:linetype] == :scatter
|
||||||
|
d[:linetype] = :none
|
||||||
|
if d[:marker] == :none
|
||||||
|
d[:marker] = :ellipse
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# add the Geoms
|
# add the Geoms
|
||||||
append!(gfargs, getLineGeoms(d))
|
append!(gfargs, getLineGeoms(d))
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ function createGadflyAnnotation(d::Dict)
|
|||||||
shape = Gadfly.circle(xs,ys,[sz])
|
shape = Gadfly.circle(xs,ys,[sz])
|
||||||
end
|
end
|
||||||
|
|
||||||
Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))
|
Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(d[:markercolor]), Gadfly.stroke(colorant"white")))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -165,19 +165,24 @@ function star1(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar =
|
|||||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||||
|
|
||||||
# some magic scalars
|
# some magic scalars
|
||||||
sx = 0.7
|
sx1, sx2, sx3 = 0.7, 0.4, 0.2
|
||||||
sy1, sy2 = 1.2, 0.4
|
sy1, sy2, sy3 = 1.2, 0.45, 0.1
|
||||||
|
|
||||||
for i in 1:n
|
for i in 1:n
|
||||||
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
x = Compose.x_measure(xs[mod1(i, length(xs))])
|
||||||
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
y = Compose.y_measure(ys[mod1(i, length(ys))])
|
||||||
r = rs[mod1(i, length(rs))]
|
r = rs[mod1(i, length(rs))]
|
||||||
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
polys[i] = Tuple{Compose.Measure, Compose.Measure}[
|
||||||
(x-sx*r, y+r), # BL
|
(x-sx1*r, y+ r), # BL
|
||||||
(x, y-sy1*r), # T
|
(x, y+sy2*r),
|
||||||
(x+sx*r, y+r), # BR
|
(x+sx1*r, y+ r), # BR
|
||||||
(x-r, y-sy2*r), # L
|
(x+sx2*r, y+sy3*r),
|
||||||
(x+r, y-sy2*r) # R
|
(x+ r, y-sy2*r), # R
|
||||||
|
(x+sx3*r, y-sy2*r),
|
||||||
|
(x, y-sy1*r), # T
|
||||||
|
(x-sx3*r, y-sy2*r),
|
||||||
|
(x- r, y-sy2*r), # L
|
||||||
|
(x-sx2*r, y+sy3*r)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -206,8 +206,9 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# build the series arg dict
|
# build the series arg dict
|
||||||
n = plt.n + i + get(d, :numUncounted, 0)
|
numUncounted = get(d, :numUncounted, 0)
|
||||||
d = getSeriesArgs(plt.plotter, getinitargs(plt, n), d, i, convertSeriesIndex(plt, n), n)
|
n = plt.n + i + numUncounted
|
||||||
|
d = getSeriesArgs(plt.plotter, getinitargs(plt, n), d, i + numUncounted, convertSeriesIndex(plt, n), n)
|
||||||
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
d[:x], d[:y] = computeXandY(xs[mod1(i,mx)], ys[mod1(i,my)])
|
||||||
|
|
||||||
if haskey(d, :idxfilter)
|
if haskey(d, :idxfilter)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user