You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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 scaleplot(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.
The text was updated successfully, but these errors were encountered:
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:
produces:
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:
This gives a somewhat cryptic error:
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.
The text was updated successfully, but these errors were encountered: