johnmyleswhite / Vega.jl

A Julia package for generating visualizations in Vega
Other
84 stars 22 forks source link

fix `historam` #141

Closed panlanfeng closed 8 years ago

panlanfeng commented 8 years ago

The function histogram does not work correctly. When relativefreq is true, the bar height should be relative frequency divided by bandwidth. In addition, the x axis of a histogram should be "linear" instead of "ordinal". After this PR, the following should work

using Distributions
using Vega
N=500
x = sort(randn(N));
xeval=linspace(-5,5,200);
yden=pdf(Normal(),xeval);

v1=histogram(x=x,relativefreq=true,bandwidth=0.2);
v2=lineplot(x=xeval,y=yden);
layer(v1,v2)

randyzwitch commented 8 years ago

Thanks, I'll take a look at this today if I can.

On Jul 24, 2016, at 6:28 PM, Lanfeng Pan notifications@github.com wrote:

The function histogram does not work correctly. When relativefreq is true, the bar height should be relative frequency divided by bandwidth. In addition, the x axis of a histogram should be "linear" instead of "ordinal". After this PR, the following should work

using Distributions using Vega N=500 x = sort(randn(N)); xeval=linspace(-5,5,200); yden=pdf(Normal(),xeval);

v1=histogram(x=x,relativefreq=true,bandwidth=0.2); v2=lineplot(x=xeval,y=yden); layer(v1,v2)

You can view, comment on, or merge this pull request online at:

https://github.com/johnmyleswhite/Vega.jl/pull/141

Commit Summary

fix historam not change bar height when y is counts File Changes

M src/derived/histogram.jl (73) M src/intermediates/add_data.jl (13) Patch Links:

https://github.com/johnmyleswhite/Vega.jl/pull/141.patch https://github.com/johnmyleswhite/Vega.jl/pull/141.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.