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
|
||||
```
|
||||
|
||||
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
|
||||
# switch to Gadfly as a backend
|
||||
gadfly!()
|
||||
gadfly!() # switch to Gadfly as a backend
|
||||
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.
|
||||
plot(rand(10,2); marker = :rect, markersize = [10,30], style = :auto)
|
||||
|
||||
# save it as a PNG
|
||||
savepng(Plots.IMG_DIR * "gadfly1.png")
|
||||
scatter(iris, :SepalLength, :SepalWidth, group=:Species, ms=12, m=[:+,:d,:s])
|
||||
```
|
||||
|
||||
which saves:
|
||||
|
||||

|
||||
|
||||
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`
|
||||
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
|
||||
`:legend` | `true` | Plot | `:leg`
|
||||
`:show` | `false` | Plot | `:display`
|
||||
`:show` | `false` | Plot | `:display`, `:gui`
|
||||
`:size` | `(800,600)` | Plot | `:windowsize`, `:wsize`
|
||||
`:title` | `` | Plot |
|
||||
`: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 DataFrames
|
||||
- [x] Grouping
|
||||
- [ ] Scales
|
||||
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
|
||||
- [ ] Custom markers
|
||||
|
||||
@ -51,21 +51,20 @@ Plots will try to figure out a good default backend for you automatically based
|
||||
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
|
||||
# switch to Gadfly as a backend
|
||||
gadfly!()
|
||||
gadfly!() # switch to Gadfly as a backend
|
||||
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.
|
||||
plot(rand(10,2); marker = :rect, markersize = [10,30], style = :auto)
|
||||
|
||||
# save it as a PNG
|
||||
savepng(Plots.IMG_DIR * "gadfly1.png")
|
||||
scatter(iris, :SepalLength, :SepalWidth, group=:Species, ms=12, m=[:+,:d,:s])
|
||||
```
|
||||
|
||||
which saves:
|
||||
|
||||

|
||||
|
||||
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 DataFrames
|
||||
- [x] Grouping
|
||||
- [ ] Scales
|
||||
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
|
||||
- [ ] 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 == :none && 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 == :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
|
||||
if lt in (:none, :ohlc)
|
||||
if lt in (:none, :ohlc, :scatter)
|
||||
return [Gadfly.Geom.path]
|
||||
end
|
||||
|
||||
@ -120,7 +120,7 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
||||
# line_style = getGadflyStrokeVector(d[:linestyle])
|
||||
|
||||
# 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]
|
||||
theme = Gadfly.Theme(; default_color = d[:color],
|
||||
line_width = line_width,
|
||||
@ -149,6 +149,13 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
|
||||
|
||||
end
|
||||
|
||||
if d[:linetype] == :scatter
|
||||
d[:linetype] = :none
|
||||
if d[:marker] == :none
|
||||
d[:marker] = :ellipse
|
||||
end
|
||||
end
|
||||
|
||||
# add the Geoms
|
||||
append!(gfargs, getLineGeoms(d))
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ function createGadflyAnnotation(d::Dict)
|
||||
shape = Gadfly.circle(xs,ys,[sz])
|
||||
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
|
||||
|
||||
|
||||
@ -165,19 +165,24 @@ function star1(xs::AbstractArray, ys::AbstractArray, rs::AbstractArray, scalar =
|
||||
polys = Vector{Vector{Tuple{Compose.Measure, Compose.Measure}}}(n)
|
||||
|
||||
# some magic scalars
|
||||
sx = 0.7
|
||||
sy1, sy2 = 1.2, 0.4
|
||||
sx1, sx2, sx3 = 0.7, 0.4, 0.2
|
||||
sy1, sy2, sy3 = 1.2, 0.45, 0.1
|
||||
|
||||
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
|
||||
(x-sx1*r, y+ r), # BL
|
||||
(x, y+sy2*r),
|
||||
(x+sx1*r, y+ r), # BR
|
||||
(x+sx2*r, y+sy3*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
|
||||
|
||||
|
||||
@ -206,8 +206,9 @@ function createKWargsList(plt::PlottingObject, x, y; kw...)
|
||||
end
|
||||
|
||||
# build the series arg dict
|
||||
n = plt.n + i + get(d, :numUncounted, 0)
|
||||
d = getSeriesArgs(plt.plotter, getinitargs(plt, n), d, i, convertSeriesIndex(plt, n), n)
|
||||
numUncounted = get(d, :numUncounted, 0)
|
||||
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)])
|
||||
|
||||
if haskey(d, :idxfilter)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user