In [2]:
import pandas as pd
import holoviews as hv
hv.extension("bokeh")
In [3]:
daily = pd.read_csv("../../home/media/data/daily.csv")
daily.head()
Out[3]:
Setting the Dimension Ranges Explicitly¶¶
In [26]:
%%opts Scatter [width=600 height=500 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True]
xdim = hv.Dimension('x', range=(0, 45000))
ydim = hv.Dimension('y', range=(0, 800000))
hv.Scatter((daily.x, daily.y), xdim, ydim)
Out[26]:
Using redim.range¶
Notice that the keyword names in redim.range must match the specified dimension names.
In [29]:
%%opts Scatter [width=600 height=500 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True]
hv.Scatter((daily.x, daily.y), 'x', 'y').redim.range(x=(0, 45000), y=(0, 800000))
Out[29]:
Use options¶
options
is the easiest way to change axis ranges.
When there are multiple subplots,
you have to either set different dimension names or use the option axiswise=True
.
In [32]:
%%opts Scatter [width=600 height=500 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True]
hv.Scatter((daily.x, daily.y)).options(xlim=(0, 45000), ylim=(0, 800000))
Out[32]:
In [5]:
%%opts Scatter [width=400 height=400 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True]
hv.Scatter((daily.x, daily.z), 'x', 'z') + \
hv.Scatter((daily.x, daily.y)).options(xlim=(0, 45000), ylim=(0, 800000))
Out[5]:
Use axiswise=True
for it to work when the dimensions of subplots are identical.
In [6]:
%%opts Scatter [width=400 height=400 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True]
hv.Scatter((daily.x, daily.z), 'x', 'y') + \
hv.Scatter((daily.x, daily.y), 'x', 'y').options(xlim=(0, 45000), ylim=(0, 800000), axiswise=True)
Out[6]:
In [7]:
%%opts Scatter [width=400 height=400 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True]
hv.Scatter((daily.x, daily.z)).options(axiswise=True) + \
hv.Scatter((daily.x, daily.y)).options(axiswise=True)
Out[7]:
In [39]:
%%opts Layout [shared_axes=False]
hv.Scatter((daily.x, daily.z)).options(axiswise=True) + hv.Scatter((daily.x, daily.y)).options(axiswise=True)
Out[39]:
In [ ]: