Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 15 15:06
    isopteryx closed #436
  • Aug 15 15:06
    isopteryx commented #436
  • Aug 15 14:58
    isopteryx commented #436
  • Aug 14 23:20
    Mattriks commented #436
  • Aug 14 16:18
    isopteryx edited #436
  • Aug 14 16:18
    isopteryx edited #436
  • Aug 14 16:17
    isopteryx edited #436
  • Aug 14 16:17
    isopteryx opened #436
  • Jul 27 18:42
    hdavid16 commented #435
  • Jul 27 18:33
    Mattriks commented #435
  • Jul 27 18:17
    Mattriks commented #435
  • Jul 27 17:54
    hdavid16 commented #435
  • Jul 27 17:53
    hdavid16 commented #435
  • Jul 27 17:52
    hdavid16 commented #435
  • Jul 27 17:50
    hdavid16 commented #435
  • Jul 27 17:44
    Mattriks commented #435
  • Jul 27 17:21
    hdavid16 commented #435
  • Jul 27 15:01
    Mattriks commented #435
  • Jul 27 14:55
    Mattriks commented #435
  • Jul 27 11:39
    hdavid16 commented #435
Mattriks
@Mattriks
The standard errors should be calculated in loess.jl (not in Gadfly). There are fast approximation methods e.g. https://doi.org/10.1007/BF01890836 (without bootstrapping)
Júlio Hoffimann
@juliohm
Will check if I can submit a PR there
Júlio Hoffimann
@juliohm
How to add text on top of a Geom.hline? I have a horizontal with a theoretical threshold in a plot, and so it would be nice to add some short text explaining what it means like Binomial limit
Mattriks
@Mattriks
Geom.label)? Use "line1\nline2" for multiline labels.
Mattriks
@Mattriks
Re: Stat.qq, I started PR #1434
Júlio Hoffimann
@juliohm
Thank you Mattriks will take a look at the plots again to incorporate your suggestions.
Júlio Hoffimann
@juliohm
@Mattriks regarding the Geom.label, I think I am trying to use Guide.annotation instead, but can't figure out from the documentation how to annotate a horizontal line produced with Geom.hline for example.
Mattriks
@Mattriks
plot(yintercept=[0.5], Geom.hline,
   x=[1.0], y=[0.5], label=["horizontal line"], Geom.label(position=:above)
)
Júlio Hoffimann
@juliohm
Thank you for you help. Will try it locally here.
Júlio Hoffimann
@juliohm

I have the following plot:

plot(df, x=Col.value(xcols...), y=:ACTUAL,
       xgroup=Col.index(xcols...), ygroup=:MODEL,
       color=:config,
       Geom.subplot_grid(layer(Geom.point), free_x_axis=true,
                         layer(yintercept=[0.0], Geom.hline(color=colors[1], style=:dash)),
                         layer(yintercept=[0.5], Geom.hline(color=colors[3], style=:dash)),
                         Coord.cartesian(ymax=0.5),
                         Guide.ylabel(orientation=:vertical)))

Tried adding the Geom.label to the last layer after the call to Geom.hline but it didn't work.

Mattriks
@Mattriks
For Geom.subplot grid, you need to do something like this:
Mattriks
@Mattriks
# in the DataFrame add label as a string or vector of strings
df2 = DataFrame(xg=["kldiv", "jaccard", "areashift"], x=rand(3), y=0.5, label="line text")
# add this layer to subplot_grid 
layer(df2, x=:x, y=:y, label=:label, xgroup=:xg, Geom.label(position=:above))
See Facets in the docs. I plan to do more work on subplot_grid after #1385.
Júlio Hoffimann
@juliohm
Thank you. Will try tomorrow when I get back to the computer.
Mattriks
@Mattriks
When using layers with multiple dataframes with subplot_grid, you may also need to use Scale.xgroup(levels=["kldiv","jaccard","areashift"]) to ensure the xgroups are ordered correctly for each dataframe (if the xgroups happen to be in the same order, things should be ok).
Júlio Hoffimann
@juliohm
Thank you I'll definitely double check that
Júlio Hoffimann
@juliohm

How do you give different label for multiple functions?

plot([sin, cos], 0, 1, label=["sin", "cos"])

didn't work. Should it work?

Mattriks
@Mattriks
plot([sin, cos], 0, 1, color=["sin", "cos"])
To understand why, see the example plot in #1420
Júlio Hoffimann
@juliohm
Thank you it worked :)
Nicholas Ritchie
@NicholasWMRitchie
I had filed (and subsequently closed) a bug report on the curious behavior I'm seeing with Gadfly 1.3.0 / Colors 0.12.2. I thought I'd beaten it but its back.
I'm using
Guide.manual_color_key(...)
I know I'm passing in a Colorant[ ], not a RGB[...], even though the contents is RGB{Float64}. I can
@assert eltype(colors)==Colorant
However, by the time it works its way through the system I get an error:
TypeError: in new, expected Array{ColorTypes.Colorant,1}, got Array{ColorTypes.RGB{Float64},1}
Nicholas Ritchie
@NicholasWMRitchie
It is as though the Array type is being mutated along the way. Now a RGB is a Colorant so there should be no problem their. Previously, I had passed in a mixed Colorant[] containing both RGB and Lab colors. This caused a entirely different issue. An
"in ccolor, abstract intersection between Color and Color{Float64,3}"
error. I can't even find reference to what an "abstract intersection" even is.
I'm currently tearing my hair out. I'd have thought I should be able to hand in a RGB[...]. Very confused.
Nicholas Ritchie
@NicholasWMRitchie
Any thoughts would be gratefully appreciated!
Nicholas Ritchie
@NicholasWMRitchie
Here is the relevant code:
    @assert eltype(palette[1:length(specs)])==Colorant
    Gadfly.with_theme(style) do
        plot(
            layers...,
            Guide.XLabel("Energy (eV)"),
            Guide.YLabel(ylbl),
            Scale.x_continuous(format = :plain),
            Scale.y_continuous(format = :plain),
            Guide.manual_color_key(length(specs) > 1 ? "Spectra" : "Spectrum", names, palette[1:length(specs)]),
            Coord.Cartesian(ymin = 0, ymax = ytransform(yscale * maxI), xmin = convert(Float64,xmin), xmax = maxE),
        )
    end
Nicholas Ritchie
@NicholasWMRitchie
The full error is
ERROR: TypeError: in new, expected Array{Colorant,1}, got Array{RGB{Float64},1}
Stacktrace:
 [1] Gadfly.Guide.ManualDiscreteKey(::String, ::Array{String,1}, ::Array{Any,1}, ::Array{RGB{Float64},1}, ::Array{Function,1}, ::Array{Measures.Measure,1}, ::Bool) at C:\Users\nritchie\.julia\packages\Gadfly\USbaq\src\guide\keys.jl:267
 [2] Gadfly.Guide.ManualDiscreteKey(; title::String, labels::Array{String,1}, pos::Array{Any,1}, color::Array{Colorant,1}, shape::Array{Function,1}, size::Array{Measures.Measure,1}) at C:\Users\nritchie\.julia\packages\Gadfly\USbaq\src\guide\keys.jl:295
 [3] #manual_color_key#131 at C:\Users\nritchie\.julia\packages\Gadfly\USbaq\src\guide\keys.jl:321 [inlined]
 [4] manual_color_key at C:\Users\nritchie\.julia\packages\Gadfly\USbaq\src\guide\keys.jl:321 [inlined]
 [5] (::NeXLSpectrum.var"#489#503"{Float64,Float64,typeof(identity),Array{Colorant,1},Tuple{Spectrum{Float64},Spectrum{Float64}},String,Array{String,1},Array{Layer,1}})() at C:\Users\nritchie\.julia\dev\NeXLSpectrum\src\gadflysupport.jl:244
 [6] with_theme(::NeXLSpectrum.var"#489#503"{Float64,Float64,typeof(identity),Array{Colorant,1},Tuple{Spectrum{Float64},Spectrum{Float64}},String,Array{String,1},Array{Layer,1}}, ::Theme) at C:\Users\nritchie\.julia\packages\Gadfly\USbaq\src\theme.jl:347
 [7] plot(::Spectrum{Float64}, ::Vararg{Spectrum{Float64},N} where N; klms::Array{Any,1}, edges::Array{Any,1}, escapes::Array{Any,1}, coincidences::Array{Any,1}, autoklms::Bool, xmin::Float64, xmax::Float64, norm::NoScaling, yscale::Float64, ytransform::typeof(identity), style::Theme, palette::Array{Colorant,1}, customlayers::Array{Layer,1}) at C:\Users\nritchie\.julia\dev\NeXLSpectrum\src\gadflysupport.jl:243
 [8] top-level scope at C:\Users\nritchie\.julia\packages\Weave\AL87K\src\run.jl:0
Nicholas Ritchie
@NicholasWMRitchie
All appears fine until the step 2 -> 1 when I believe parse_colorant(c::Union{Tuple,Vector}) = [parse_colorant(x) for x in c] is taking a Colorant[] and returning a RGB[].
Mattriks
@Mattriks
This example works for me:
palette = [RGB(1,0,0), RGB(0,1,0)]
names, specs = randstring.([4, 5]), [1,2]

Gadfly.with_theme(style()) do
p = plot(Geom.blank,
    Guide.XLabel("Energy (eV)"), Guide.YLabel("ylbl"),
    Scale.x_continuous(format = :plain),   Scale.y_continuous(format = :plain),
    Guide.manual_color_key(length(specs) > 1 ? "Spectra" : "Spectrum", names, palette[1:length(specs)]),
#    Coord.Cartesian(ymin = 0, ymax = ytransform(yscale * maxI), xmin = convert(Float64,xmin), xmax = maxE)
)
end
Nicholas Ritchie
@NicholasWMRitchie

I'm really confused. The color argument is a ::Array{Colorant,1} in stacktrace [2] but becomes an ::Array{RGB{Float64},1} in stacktrace [2] in the error message above. I believe this is because it is passed through parse_colorant(...) which Compose says parse_colorant(c::Union{Tuple,Vector}) = [parse_colorant(x) for x in c]. This does in fact convert a ::Array{Colorant,1} to a ::Array{RGB{Float64},1} like this:

cols=Compose.parse_colorant(Colorant[ RGB(1,0,0), RGB(0,1,0) ])
 2-element Array{RGB{N0f8},1} with eltype RGB{FixedPointNumbers.Normed{UInt8,8}}:
 RGB{N0f8}(1.0,0.0,0.0)
 RGB{N0f8}(0.0,1.0,0.0)

Now Gadfly.Guide.ManualDiscreteKey(...) takes an ::Array{Colorant,1} not a ::Array{RGB,1} or an ::Array{<:Colorant,1} and when handed a Array{RGB,1} I see it fail. (I don't understand why you don't.)

If there is in fact a problem, there would be two ways to resolve this:

# In Compose, add Colorant to the return array definition
parse_colorant(c::Union{Tuple,Vector}) = Colorant[parse_colorant(x) for x in c]
# In Gadfly, change color::Array{Colorant,1} to color::Array{<:Colorant,1}
Gadfly.Guide.ManualDiscreteKey(; title::String, labels::Array{String,1}, pos::Array{Any,1}, color::Array{<:Colorant,1}, shape::Array{Function,1}, size::Array{Measures.Measure,1})

The Compose change is more likely to cause other problems. The Gadfly change is more focused.

However, while I see a problem, you don't and I can't figure out what in my code is causing the difference in results. That is why I closed the bug report but none-the-less believe there is something wrong here. I just can't put my finger on it.

Nicholas Ritchie
@NicholasWMRitchie

I have solved my problem by adding

Gadfly.parse_colorant(c::Array{Colorant,1}) = c

to my code. If someone else reports the problem, you might considering adding similar code to Compose.jl.

Thanks for your patience.

Mattriks
@Mattriks
I don't think it's correct to say that "Gadfly.ManualDiscreteKey(...) takes an ::Array{Colorant, 1}". A constructor converts any of its arguments into it's specified fieldtypes, and here's an example:
struct mytype
   i::Float64    
end
mytype(1)
Nicholas Ritchie
@NicholasWMRitchie

I believe that you are correct. However, that doesn't explain the error I see.

ERROR: TypeError: in new, expected Array{Colorant,1}, got Array{RGB{Float64},1}
Stacktrace:
    [1] Gadfly.Guide.ManualDiscreteKey(::String, ::Array{String,1}, ::Array{Any,1}, ::Array{RGB{Float64},1}, ::Array{Function,1}, ::Array{Measures.Measure,1}, ::Bool) at C:\Users\nritchie\.julia\packages\Gadfly\USbaq\src\guide\keys.jl:267

Why isn't the Array{RGB{Float64},1} being converted to an Array{Colorant,1} as you indicate it should...
Which suggests to me that there is something deeper going on. (I don't want to say compiler issue but???)

Mattriks
@Mattriks
In your post https://github.com/GiovineItalia/Gadfly.jl/issues/1454#issuecomment-643618204 you say the basic example works. Is your package code available?
Alan Crawford
@alancrawford
Hi, I am wondering if it is possible to add chart titles onto subplots in Gadfly?
Mattriks
@Mattriks
Not yet, but you can do something like this:
using RDatasets
data = dataset("datasets", "CO2")
labels=["Title 1", "Title 2", "Title 3","Title 4" ]
titledata = DataFrame(label=labels, x=500, y=58, 
    Type=unique(data.Type)[[1,2,1,2]], Treatment=unique(data.Treatment)[[1,1,2,2]] )
coord = Coord.cartesian(ymin=0, ymax=60)

p = plot(data, xgroup=:Type, ygroup=:Treatment,
Geom.subplot_grid(coord,
    layer(data, x=:Conc, y=:Uptake,  xgroup=:Type, ygroup=:Treatment, Geom.point),
    layer(titledata, x=:x, y=:y, label=:label, xgroup=:Type, ygroup=:Treatment, Geom.label(position=:centered)),
    Guide.yticks(ticks=collect(0:10:50))
),       
    Guide.title("Title of Plot"), Guide.xlabel("Concentration"), Guide.ylabel("Uptake"))
Alan Crawford
@alancrawford
Thanks.
Tamas Nagy
@tlnagy
Hi @Mattriks, I was thinking about what would be necessary to add Tables.jl support to Gadfly and I was wondering whether we still need all the stuff in src/mapping.jl
Seems like our DataFrames.jl specific stuff lives there and might not be necessary any more
Mattriks
@Mattriks
Discussion of Tables support in #1292. The stuff in DataFrames.jl could be changed with Tables support (not sure about src/mapping.jl - it's used for other things).
Tamas Nagy
@tlnagy
Yeah, I had seen the discussion in #1292 and was trying to gauge how difficult it would be to generalize our DataFrames specific code
I'm not familiar with why we have all the melted data stuff there, any idea what that does?
Hmm, this issue seems to explore it GiovineItalia/Gadfly.jl#1451
Mattriks
@Mattriks
The stuff in mapping.jl maps from layer.data_source to aesthetics. It can even be customised for custom types (#1474)
Evan Thomas
@evan-wehi

Plotting histograms with log scales seems to be not working quite right in some scenarios.

plot(x=ones(20), Geom.histogram)

works as expected but

plot(x=ones(20), Geom.histogram, Scale.x_log10)

plots the values centred on x=100.5.

There is also an issue with Cood.cartesian and log scales.

plot(x=ones(20), Scale.x_log10, Geom.histogram, Coord.cartesian(xmin=-1, xmax=1))

plots from 10^-1 to 100.1. From other plots, xmin and xmax seem to apply log values and not the actually values which was surprising at first.

Devin Kelly
@dwwkelly
Hey I have a plotting question with Gadfly, is this a good place to ask it?
Devin Kelly
@dwwkelly
Well, the question is about gridstack(). It looks like I can only stack up plots where all the subplots are evenly spaced. Is it possible to make a set of plots that are 2x2 where the column of plots on the left are twice as wide as the column of plots on the right for example?
1 reply