[julia-users] Re: Fill below a density plot with color in Winston

2015-11-10 Thread milktrader


> The solution to the two-color problem is ...
>

using Winston, KernelDensity
 
k = kde(rand(100))

k1 = k.x[k.x .< .5];

k2 = k.x[k.x .> .5];

f1 = FillBelow(k1, k.density[1:length(k1)], color="blue");

f2 = FillBelow(k2, k.density[length(k1)+1:end], color="red");

p = FramedPlot()

add(p, f1, f2)





[julia-users] Re: Fill below a density plot with color in Winston

2015-11-10 Thread milktrader
To answer question #1 only, this works ...

using Winston, KernelDensity

k = kde(rand(100))

fieldnames(k)

# outputs ...

# 2-element Array{Symbol,1}:
# :x  
# :density

f = FillBelow(k.x, k.density, color="blue")
p = FramedPlot()
add(p,f)















So now the only question is how to split this into two colors.







On Tuesday, November 10, 2015 at 11:55:20 AM UTC-5, milktrader wrote:
>
> Suppose you have a density plot ...
>
> using Winston, KernelDensity
>
> k = kde(rand(100))
>
> Winston.plot(k)
>
> Which would look something similar to this:
>
>
> 
> 1) How can you fill below the curve with color? The two candidates 
> for available methods include FillBelow()and FillBetween().
>
> 2) Is it then possible to fill below the curve from 0:0.5 with one color 
> and below the curve from 0.5:1 with another color?
>


[julia-users] Re: Fill below a density plot with color in Winston

2015-11-10 Thread milktrader
I'll be honest, the code to do this in R is substantially more 
non-intuitive. Nice work Mike!

On Tuesday, November 10, 2015 at 12:51:32 PM UTC-5, milktrader wrote:
>
>
> The solution to the two-color problem is ...
>>
>
> using Winston, KernelDensity
>  
> k = kde(rand(100))
>
> k1 = k.x[k.x .< .5];
>
> k2 = k.x[k.x .> .5];
>
> f1 = FillBelow(k1, k.density[1:length(k1)], color="blue");
>
> f2 = FillBelow(k2, k.density[length(k1)+1:end], color="red");
>
> p = FramedPlot()
>
> add(p, f1, f2)
>
>
> 
>
>