Lets-Plot now uses the HCL
color model instead of HLV
. This change affects hue scale and gradient scales (both color and greyscale).
from lets_plot import *
LetsPlot.setup_html()
data = { 'x': ['A', 'B', 'C', 'D', 'E', 'F'] }
p = ggplot(data) \
+ geom_boxplot(aes(x='x', fill='x'), stat='identity', lower=25, middle=50, upper=75, ymin=0, ymax=100)
Palette for discrete data:
p + scale_fill_hue()
Hue gradient:
data = {
'x': list(range(256))
}
ggplot(data) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_hue() \
+ scale_color_hue() \
+ coord_cartesian() \
+ ggsize(800, 200)
Gradient:
df = {
'x': list(range(256))
}
ggplot(df) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_gradient(low="#00FF00", high="#FF0000") \
+ scale_color_gradient(low="#00FF00", high="#FF0000") \
+ coord_cartesian() \
+ ggsize(800, 200)
Gradientn
df = {
'x': list(range(256))
}
ggplot(df) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_gradientn(colors=["#00FF00", "#FF0000", "#0000FF"]) \
+ scale_color_gradientn(colors=["#00FF00", "#FF0000", "#0000FF"]) \
+ coord_cartesian() \
+ ggsize(800, 200)
Greyscale gradient:
df = {
'x': list(range(256))
}
ggplot(df) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_color_grey(start=0.1, end=0.9) \
+ scale_fill_grey(start=0.1, end=0.9) \
+ coord_cartesian() \
+ ggsize(800, 200)
Viridis
df = {
'x': list(range(256))
}
ggplot(df) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_viridis() \
+ scale_color_viridis() \
+ coord_cartesian() \
+ ggsize(800, 200)
Parameter h_start
now works with descrete data:
p + scale_fill_hue(h_start=180)
Parameter l
now correctly controls lightness:
p + scale_fill_hue(c=95, l=75) + ggtitle('scale_fill_hue(c=95, l=75)')
def dump_spec(plot, display=None):
import json
try:
import clipboard
except:
clipboard = None
from lets_plot._type_utils import standardize_dict
plot_dict = standardize_dict(plot.as_dict())
plot_json = json.dumps(plot_dict, indent=2)
if clipboard:
clipboard.copy('')
clipboard.copy(str(plot_json))
else:
if display is None:
display = True
if display:
print(plot_json)
return plot
data = {
'x': list(range(60))
}
dump_spec(ggplot(data) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_hue() \
+ scale_color_hue() \
+ coord_cartesian() \
+ ggsize(600, 200))
dump_spec(ggplot(data) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_grey() \
+ scale_color_grey() \
+ coord_cartesian() \
+ ggsize(600, 200))
df = { 'x': list(range(59)) }
dump_spec(
ggplot(df) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1, height=40) \
+ scale_fill_gradient(low="#00FF00", high="#FF0000") \
+ scale_color_gradient(low="#00FF00", high="#FF0000")
)
ggplot(df) + geom_tile(aes(x='x', fill='x'), height=40) + scale_fill_gradient(low = "yellow", high = "red")
dump_spec(p + scale_fill_hue(h = [15, 375], c = 100, l = 100))
df = {
'x': list(range(256))
}
ggplot(df) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_viridis() \
+ scale_color_viridis() \
+ coord_cartesian() \
+ ggsize(800, 400)
ggplot(df) \
+ geom_tile(aes(x='x', fill='x', color='x'), size=1) \
+ scale_fill_viridis() \
+ scale_color_viridis(option='A') \
+ coord_cartesian() \
+ ggsize(800, 400)