Is there a way to define the ymin and ymax of hl.plot.scatter
?
You can do this on the bokeh Figure returned by scatter:
from bokeh.models import Range1d
fig = # hail scatter plot
left, right, bottom, top = 3, 9, 4, 10
fig.x_range=Range1d(left, right)
fig.y_range=Range1d(bottom, top)
show(fig)
source:
Hmm i tried that but it do not works:
fig = hl.plot.scatter(
mt.col_idx,
mt.sample_qc.r_ti_tv,
title='Ts/Tv by sample',
xlabel='Sample',
ylabel='Ratio Ti/Tv',
size=10,
legend=False
)
fig.y_range=Range1d(1,3)
show(fig)
Fail to execute line 12: fig.y_range=Range1d(1,3)
Traceback (most recent call last):
File "/tmp/zeppelin_pyspark-633426455684725232.py", line 375, in <module>
exec(code, _zcUserQueryNameSpace)
File "<stdin>", line 12, in <module>
File "/usr/local/lib/python3.6/site-packages/bokeh/core/has_props.py", line 288, in __setattr__
(name, self.__class__.__name__, text, nice_join(matches)))
AttributeError: unexpected attribute 'y_range' to Column, possible attributes are align, aspect_ratio, background, children, css_classes, disabled, height, height_policy, js_event_callbacks, js_property_callbacks, margin, max_height, max_width, min_height, min_width, name, rows, sizing_mode, spacing, subscribed_events, tags, visible, width or width_policy
Seems like fig is not a Figure but a Column !
ack, annoying – this is actually a bokeh Column object:
try:
plt = hl.plot.scatter(
mt.col_idx,
mt.sample_qc.r_ti_tv,
title='Ts/Tv by sample',
xlabel='Sample',
ylabel='Ratio Ti/Tv',
size=10,
legend=False
)
fig = plt.children[1]
fig.y_range=Range1d(1,3)
show(plt)
Great ! that works.
Not easy when a function might return 2 different type of object…
is there a way to return a Bokeh Figure anyway ? that would be more conveninent.