Issue #1489: scale_color_gradient(): guide='legend' should render a colorbar

In [ ]:
from lets_plot import *

LetsPlot.setup_html()

Reproduction - guide='legend' on a continuous scale

A continuous color scale with guide='legend' should render discrete legend keys instead of a colorbar.

In [ ]:
data = {'x': [1, 2, 3, 4, 5], 'y': [2, 4, 1, 5, 3], 'v': [10, 20, 30, 40, 50]}

(
    ggplot(data, aes('x', 'y', color='v'))
    + geom_point(size=5)
    + scale_color_gradient(low='blue', high='red', guide='legend')
    + ggtitle("guide='legend' on a continuous color scale - should show legend keys")
)

Comparison - default behavior still shows a colorbar

Without an explicit guide, the continuous color scale should keep its default colorbar.

In [ ]:
(
    ggplot(data, aes('x', 'y', color='v'))
    + geom_point(size=5)
    + scale_color_gradient(low='blue', high='red')
    + ggtitle('No guide parameter - the default colorbar should still appear')
)

Regression test - guide='colorbar' still works

An explicit colorbar guide should continue to render as a colorbar.

In [ ]:
(
    ggplot(data, aes('x', 'y', color='v'))
    + geom_point(size=5)
    + scale_color_gradient(low='blue', high='red', guide='colorbar')
    + ggtitle("Explicit guide='colorbar' - should still show a colorbar")
)

Regression test - guide='none' still works

Suppressing the guide should continue to hide it completely.

In [ ]:
(
    ggplot(data, aes('x', 'y', color='v'))
    + geom_point(size=5)
    + scale_color_gradient(low='blue', high='red', guide='none')
    + ggtitle("guide='none' - no guide should appear")
)

Regression test - scale_fill_gradient with guide='legend'

The same guide behavior should apply to continuous fill scales.

In [ ]:
tile_data = {
    'x': [1, 2, 3, 1, 2, 3],
    'y': [1, 1, 1, 2, 2, 2],
    'v': [10, 20, 30, 40, 50, 60]
}

(
    ggplot(tile_data, aes('x', 'y', fill='v'))
    + geom_tile()
    + scale_fill_gradient(low='white', high='darkblue', guide='legend')
    + ggtitle("scale_fill_gradient guide='legend' - fill scale should respect guide='legend'")
)