GiovineItalia / Gadfly.jl

Crafty statistical graphics for Julia.
http://gadflyjl.org/stable/
Other
1.9k stars 251 forks source link

Shapekey does not seem to take values other than float #1214

Closed hanlulong closed 6 years ago

hanlulong commented 6 years ago

In the manual, it states that pos in Guide.shapekey can be defined as relative values, e.g., [0.7w, 0.2h]. However, from the way the function is written, it will only take absolute values, e.g., [0.7,0.2].

Did I miss anything? I have multiple legends and am trying to control the relative position of the shape legend.

""" Guide.shapekey[(; title="Shape", labels=[""], pos=Float64[])] Guide.shapekey(title, labels, pos) Enable control of the auto-generated shapekey. Set the key title and the item labels. pos overrides [Theme(key_position=)](@ref Gadfly) and can be in either relative (e.g. [0.7w, 0.2h] is the lower right quadrant), absolute (e.g. [0mm, 0mm]), or plot scale (e.g. [0,0]) coordinates. """

Many thanks, Lu

Mattriks commented 6 years ago

Yes, you did. There is an example in the Gadfly guide gallery.

Also read the section on Keyword arguments in the Julia docs. The Float64[] is a default value, not a type assertion.

hanlulong commented 6 years ago

Thanks. When I use [0.7w, 0.2h] or [0.18w,-0.315h], it gives me an error "w not found..."

ERROR: LoadError: UndefVarError: w not defined

I am working with Julia 0.6.4 and Gadfly v"0.8.0"

Mattriks commented 6 years ago

As shown in the gallery example, you need to start with using Compose, Compose is a graphics package.

hanlulong commented 6 years ago

It works now. Thank you.

I have two more questions: a) Is there an option to limit the number of rows of legend entries? I would like to restrict my legend labels into one row. I see there is an option to limit the number of columns. I wonder if there is a way to restrict the number of rows.

b) Would it be possible to adjust the legend outside the plotting region? I would like to have something like: "Set of legend 1 Set of Legend 2" " Graph "

Thank you again for your help!

Mattriks commented 6 years ago

For a) and b) not yet! Gadfly is in development, and both features are likely to be future developments. If you want to know about hacking Gadfly guides, see this old post, and read the comment lines in the example.