-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rectbin errors out when given max and min values #845
Comments
You could just draw a polygon instead. Or make the line invisible (0 width On Monday, May 16, 2016, Roger Herikstad notifications@github.com wrote:
|
According to the guide (http://dcjones.github.io/Gadfly.jl/geom_rectbin.html), using Colors, Compose, DataFrames
immutable RectangleGeometry <: Gadfly.GeometryElement
tag::Symbol
function RectangleGeometry(; tag::Symbol=Gadfly.Geom.empty_tag)
new(tag)
end
end
function Gadfly.element_aesthetics(::RectangleGeometry)
[:xmin, :ymin, :xmax, :ymax, :color]
end
function Gadfly.render(geom::RectangleGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics)
default_aes = Gadfly.Aesthetics()
default_aes.color = DataArrays.PooledDataArray(RGBA{Float32}[theme.default_color])
aes = Gadfly.inherit(aes, default_aes)
alpha_color = map(theme.lowlight_color, aes.color)
ctx = context()
compose!(ctx, rectangle(aes.xmin, aes.ymin,
aes.xmax-aes.xmin, aes.ymax-aes.ymin, geom.tag), fill(alpha_color))
return compose!(context(order=4), svgclass("geometry"), ctx)
end
rect1 = RectangleGeometry
# in the next line, opacity = 0.2
theme1 = Theme(lowlight_color=c -> RGBA(c.r, c.g, c.b, 0.2))
D = DataFrame( x1=[-2,0], y1=[-1,0], x2=[1,4], y2=[1,2], col=["a","b"] )
p = plot(
layer(x=1:5, y=randn(5), Geom.point, Theme(default_color=colorant"red")),
layer(D, xmin=:x1, ymin=:y1, xmax=:x2, ymax=:y2, color=:col, rect1, theme1)
)
|
That works beautifully, thanks! |
fixed by #993 |
For some of my plots, I like to add a rectangular shaded region to highlight e.g. a sub-region used for a statistical comparison between two distributions. In Winston, I can accomplish this using the FillBetween type. I noticed that Gadfly has the ribbon geometry, but that seems to be bound to a line, i.e. it will only draw a ribbon around an existing line. It would be really useful to have a dedicated ShadedRegion (or a more fitting name) geometry for this use.
The text was updated successfully, but these errors were encountered: