Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble using Scale.continuous_scale_partial with the color aesthetic #573

Closed
durcan opened this issue Mar 30, 2015 · 0 comments · Fixed by #1245
Closed

Trouble using Scale.continuous_scale_partial with the color aesthetic #573

durcan opened this issue Mar 30, 2015 · 0 comments · Fixed by #1245

Comments

@durcan
Copy link

durcan commented Mar 30, 2015

When plotting bivariate histograms it is often desirable to use a log color scale so most of the dynamic range of the color scale is not used by a few of the bins. As an example, lets look at the "diamond" data-set and look at the carats vs price distribution:

using Lazy, Gadfly, RDatasets

d = dataset("ggplot2", "diamonds")

plot(d,
x=:Price,
y=:Carat,
Geom.hexbin(xbincount=70, ybincount=70)) |>
x->draw(SVG(15cm, 15cm), x)

produces:
screen shot 2015-03-29 at 8 10 09 pm

Much of the structure of the long tail is hidden as the dynamic range is dominated by a few of the bins in the lower left of the plot. There is no Scale.color_log10, so using the definition as Scale.y_log10 as a rubric, I attempted to roll one myself:

color_log10 = Scale.continuous_scale_partial([:color], Scale.log10_transform) # define the scale

plot(d,
x=:Price,
y=:Carat,
color_log10, # use the new scale
Geom.hexbin(xbincount=60, ybincount=60)) |>
x->draw(PNG(15cm, 15cm), x)

This gives a somewhat cryptic error:

HexBinGeometry requires a continuous color scale.
while loading In[3], in expression starting on line 3

Especially given that color_log10 does seem to be a ContinuousScale constructor. Is this not the correct approach to modify color scales? I know that there are methods to produce entirely new scales (like Scale.ContinuousColorScale) but it is hard to make a sensible color scale when them (let alone one that is not linearly scaled). If there is a correct approach to this sort of problem it would be great to make it more accessible / documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant