Here are the examples of the python api bokeh.models.formatters.PrintfTickFormatter taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
0
Source : interact.py
with MIT License
from nasa
with MIT License
from nasa
def make_tpf_figure_elements(tpf, tpf_source, pedestal=0, fiducial_frame=None,
plot_width=370, plot_height=340):
"""Returns the lightcurve figure elements.
Parameters
----------
tpf : TargetPixelFile
TPF to show.
tpf_source : bokeh.plotting.ColumnDataSource
TPF data source.
fiducial_frame: int
The tpf slice to start with by default, it is assumed the WCS
is exact for this frame.
pedestal: float
A scalar value to be added to the TPF flux values, often to avoid
taking the log of a negative number in colorbars
Returns
-------
fig, stretch_slider : bokeh.plotting.figure.Figure, RangeSlider
"""
if tpf.mission in ['Kepler', 'K2']:
title = 'Pixel data (CCD {}.{})'.format(tpf.module, tpf.output)
elif tpf.mission == 'TESS':
title = 'Pixel data (Camera {}.{})'.format(tpf.camera, tpf.ccd)
else:
title = "Pixel data"
fig = figure(plot_width=plot_width, plot_height=plot_height,
x_range=(tpf.column, tpf.column+tpf.shape[2]),
y_range=(tpf.row, tpf.row+tpf.shape[1]),
title=title, tools='tap,box_select,wheel_zoom,reset',
toolbar_location="below",
border_fill_color="whitesmoke")
fig.yaxis.axis_label = 'Pixel Row Number'
fig.xaxis.axis_label = 'Pixel Column Number'
vlo, lo, hi, vhi = np.nanpercentile(tpf.flux - pedestal, [0.2, 1, 95, 99.8])
vstep = (np.log10(vhi) - np.log10(vlo)) / 300.0 # assumes counts >> 1.0!
color_mapper = LogColorMapper(palette="Viridis256", low=lo, high=hi)
fig.image([tpf.flux[fiducial_frame, :, :] - pedestal], x=tpf.column, y=tpf.row,
dw=tpf.shape[2], dh=tpf.shape[1], dilate=True,
color_mapper=color_mapper, name="tpfimg")
# The colorbar will update with the screen stretch slider
# The colorbar margin increases as the length of the tick labels grows.
# This colorbar share of the plot window grows, shrinking plot area.
# This effect is known, some workarounds might work to fix the plot area:
# https://github.com/bokeh/bokeh/issues/5186
color_bar = ColorBar(color_mapper=color_mapper,
ticker=LogTicker(desired_num_ticks=8),
label_standoff=-10, border_line_color=None,
location=(0, 0), background_fill_color='whitesmoke',
major_label_text_align='left',
major_label_text_baseline='middle',
title='e/s', margin=0)
fig.add_layout(color_bar, 'right')
color_bar.formatter = PrintfTickFormatter(format="%14u")
if tpf_source is not None:
fig.rect('xx', 'yy', 1, 1, source=tpf_source, fill_color='gray',
fill_alpha=0.4, line_color='white')
# Configure the stretch slider and its callback function
stretch_slider = RangeSlider(start=np.log10(vlo),
end=np.log10(vhi),
step=vstep,
title='Screen Stretch (log)',
value=(np.log10(lo), np.log10(hi)),
orientation='horizontal',
width=200,
direction='ltr',
show_value=True,
sizing_mode='fixed',
name='tpfstretch')
def stretch_change_callback(attr, old, new):
"""TPF stretch slider callback."""
fig.select('tpfimg')[0].glyph.color_mapper.high = 10**new[1]
fig.select('tpfimg')[0].glyph.color_mapper.low = 10**new[0]
stretch_slider.on_change('value', stretch_change_callback)
return fig, stretch_slider
def make_default_export_name(tpf, suffix='custom-lc'):
0
Source : visualization.py
with MIT License
from pedromartins4
with MIT License
from pedromartins4
def plot_rsi(stock):
p = figure(x_axis_type="datetime", plot_width=WIDTH_PLOT, plot_height=200, title="RSI 15 days",
tools=TOOLS, toolbar_location='above')
p.line(x='date', y='rsi_15', line_width=2, color=BLUE, source=stock)
low_box = BoxAnnotation(top=30, fill_alpha=0.1, fill_color=RED)
p.add_layout(low_box)
high_box = BoxAnnotation(bottom=70, fill_alpha=0.1, fill_color=GREEN)
p.add_layout(high_box)
# Horizontal line
hline = Span(location=50, dimension='width', line_color='black', line_width=0.5)
p.renderers.extend([hline])
p.y_range = Range1d(0, 100)
p.yaxis.ticker = [30, 50, 70]
p.yaxis.formatter = PrintfTickFormatter(format="%f%%")
p.grid.grid_line_alpha = 0.3
return p
#### On-Balance Volume (OBV)
def plot_obv(stock):