GiovineItalia / Gadfly.jl

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

Rectbin issue with log10 scales #483

Open tpoisot opened 9 years ago

tpoisot commented 9 years ago

I have a bunch of data on two log10 axes. All points are evenly spaced, but rectbin is doing a weird thing: the last bin is stretched a lot (that happens in either directions).

rectbin

Here is the code I use:

draw(
   PDF("modularity.pdf", 36cm, 12cm),
   plot(aggregates, x="e", y="c", xgroup="p", color="Modularity", Geom.subplot_grid(Geom.rectbin), Scale.x_log10, Scale.y_log10)
)
felixjung commented 9 years ago

I think I might be having the same issue. In my case I'm trying to plot firms entering and leaving a sample over the overall sample period. The values used for colours are only [0, 1, 2, 3] and assigned manually using Scale.color_discrete_manual().You can see a blue rectangle in the top left of my plot. It does not seem to be present in my data. If I exclude half the firms from the sample I get a similar artefact, but stretched over many more periods. active_firms Here's my code:

## Create a data frame for plotting
data = DataFrame(Firm = firms_alive[:, 1], Period = firms_alive[:, 2],
    Exittype = firms_alive[:, 3])

## Create heatmap plot
pl = plot(data, x="Period", y = "Firm", color="Exittype", Geom.rectbin, theme_presentation(),
    Scale.color_discrete_manual("white", "green", "red", "blue"; levels = [0, 1, 2, 3]),
    Guide.yticks(ticks=[0:300:2100]), Guide.xticks(ticks=[0:25:250]))