question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Datashading a vertical or horizontal line created with Holoviews Curve generates empty plot

See original GitHub issue

Description

I plot a lot of curves and sometimes the data is naturally a horizontal line. When attempting to Datashade a vertical or horizontal line created with Holoviews Curve an empty plot is generated. This error further propagates to any layouts since the resulting empty plot has axes that don’t match with other successful plots.

Code: Imports

import holoviews as hv
import holoviews.operation.datashader as hd
import pandas as pd
hv.extension('matplotlib')
import logging

Holoviews curve and plot working as expected:

a_line = hv.Curve(([1, 2, 3], [1, 2, 3]))
a_line

a_line_hv

hd.datashade(a_line)

a_line_ds

Horizontal Line producing empty datashade plot:

h_line = hv.Curve(([1, 2, 3],[3, 3, 3]))
h_line

h_line_hv

hd.datashade(h_line)

h_line_ds

Vertical Line producing empty datashade plot:

v_line = hv.Curve(([3, 3, 3], [1, 2, 3]))
v_line

v_line_hv

hd.datashade(v_line)

v_line_ds

Errors and warnings

Running the same code but with matplotlib as holoviews extentions produces slightly more insightful errors.

hv.extension('matplotlib')
h_line = hv.Curve(([1, 2, 3],[3, 3, 3]))
h_line
hd.datashade(h_line)

ValueError [Call holoviews.ipython.show_traceback() for details] zero-size array to reduction operation minimum which has no identity matplotlib_empty

Environment

Running Jupyter Notebook on macOS Catalina version 10.15.1

conda list
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py27_0
addict                    2.2.0                    pypi_0    pypi
alabaster                 0.7.12                   py27_0
anaconda-client           1.7.2                    py27_0
anaconda-navigator        1.9.7                    py27_0
anaconda-project          0.8.4                      py_0
appnope                   0.1.0            py27hb466136_0
appscript                 1.1.0            py27h1de35cc_0
asn1crypto                1.2.0                    py27_0
astroid                   1.6.5                    py27_0
astropy                   2.0.9            py27h1d22016_0
atomicwrites              1.3.0                    py27_1
attrs                     19.3.0                     py_0
babel                     2.7.0                      py_0
backports                 1.0                        py_2
backports.functools_lru_cache 1.5                        py_2
backports.os              0.1.1                    py27_0
backports.shutil_get_terminal_size 1.0.0                    py27_2
backports.tempfile        1.0                        py_1
backports.weakref         1.0.post1                  py_1
backports_abc             0.5              py27h6972548_0
beautifulsoup4            4.8.1                    py27_0
bitarray                  1.0.1            py27h1de35cc_0
bkcharts                  0.2              py27haafc882_0
blas                      1.0                         mkl
bleach                    3.1.0                    py27_0
blosc                     1.16.3               hd9629dc_0
bokeh                     1.3.4                    py27_0
boto                      2.49.0                   py27_0
bottleneck                1.2.1            py27h1d22016_1
bzip2                     1.0.8                h1de35cc_0
ca-certificates           2019.10.16                    0
cdecimal                  2.3              py27h1de35cc_3
certifi                   2019.9.11                py27_0
cffi                      1.13.1           py27hb5b8e2f_0
chardet                   3.0.4                 py27_1003
click                     7.0                      py27_0
cloudpickle               1.2.2                      py_0
clyent                    1.2.2                    py27_1
colorama                  0.4.1                    py27_0
colorcet                  2.0.2                      py_0
conda-package-handling    1.6.0            py27h1de35cc_0
conda-verify              3.4.2                      py_1
configparser              4.0.2                    py27_0
contextlib2               0.6.0                      py_0
cryptography              2.8              py27ha12b0ac_0
curl                      7.65.3               ha441bb4_0
cycler                    0.10.0           py27hfc73c78_0
cython                    0.29.13          py27h0a44026_0
cytoolz                   0.10.0           py27h1de35cc_0
dask                      1.2.2                      py_0
dask-core                 1.2.2                      py_0
datashader                0.8.0                      py_0
datashape                 0.5.4                    py27_1
dbus                      1.13.12              h90a0687_0
decorator                 4.4.1                      py_0
defusedxml                0.6.0                      py_0
dill                      0.3.0                    py27_0
distributed               1.28.1                   py27_0
docutils                  0.15.2                   py27_0
entrypoints               0.3                      py27_0
enum34                    1.1.6                    py27_1
epimetheus                0.1.dev0                 pypi_0    pypi
et_xmlfile                1.0.1            py27hc42f929_0
expat                     2.2.6                h0a44026_0
fastcache                 1.1.0            py27h1de35cc_0
filelock                  3.0.12                     py_0
flask                     1.1.1                      py_0
flask-cors                3.0.8                      py_0
freetype                  2.9.1                hb4e5f40_0
funcsigs                  1.0.2            py27hb9f6266_0
functools32               3.2.3.2                  py27_1
future                    0.17.1                   py27_0
futures                   3.3.0                    py27_0
get_terminal_size         1.0.0                h7520d66_0
gettext                   0.19.8.1             h15daf44_3
gevent                    1.4.0            py27h1de35cc_0
glib                      2.56.2               hd9629dc_0
glob2                     0.7                        py_0
gmp                       6.1.2                hb37e062_1
gmpy2                     2.0.8            py27h6ef4df4_2
greenlet                  0.4.15           py27h1de35cc_0
grin                      1.2.1                    py27_4
h5py                      2.9.0            py27h3134771_0
hdf5                      1.10.4               hfa1e0ec_0
heapdict                  1.0.1                      py_0
holoviews                 1.12.6                     py_0
html5lib                  1.0.1                    py27_0
http-parser               0.8.3                    pypi_0    pypi
icu                       58.2                 h4b95b61_1
idna                      2.8                      py27_0
imageio                   2.6.1                    py27_0
imagesize                 1.1.0                    py27_0
importlib_metadata        0.23                     py27_0
intel-openmp              2019.4                      233
ipaddress                 1.0.23                     py_0
ipykernel                 4.10.0                   py27_0
ipython                   5.8.0                    py27_0
ipython_genutils          0.2.0            py27h8b9a179_0
ipywidgets                7.5.1                      py_0
isort                     4.3.21                   py27_0
itsdangerous              1.1.0                    py27_0
jbig                      2.1                  h4d881f8_0
jdcal                     1.4.1                      py_0
jedi                      0.15.1                   py27_0
jinja2                    2.10.3                     py_0
jpeg                      9b                   he5867d9_2
jsonschema                3.1.1                    py27_0
jupyter                   1.0.0                    py27_7
jupyter_client            5.3.4                    py27_0
jupyter_console           5.2.0                    py27_1
jupyter_core              4.6.0                    py27_0
jupyterlab                0.33.11                  py27_0
jupyterlab_launcher       0.11.2           py27h28b3542_0
keyring                   18.0.0                   py27_0
kiwisolver                1.1.0            py27h0a44026_0
krb5                      1.16.1               hddcf347_7
lazy-object-proxy         1.4.2            py27h1de35cc_0
libcurl                   7.65.3               h051b688_0
libcxx                    4.0.1                hcfea43d_1
libcxxabi                 4.0.1                hcfea43d_1
libedit                   3.1.20181209         hb402a30_0
libffi                    3.2.1                h475c297_4
libgfortran               3.0.1                h93005f0_2
libiconv                  1.15                 hdd342a3_7
libopenblas               0.3.6                hdc02c5d_1
libpng                    1.6.37               ha441bb4_0
libsodium                 1.0.16               h3efe00b_0
libssh2                   1.8.2                ha12b0ac_0
libtiff                   4.0.10               hcb84e12_2
libxml2                   2.9.9                hf6e021a_1
libxslt                   1.1.33               h33a18ac_0
linecache2                1.0.0                    py27_0
llvmlite                  0.30.0           py27h98b8051_0
locket                    0.2.0            py27ha10513d_1
lxml                      4.4.1            py27hef8c89e_0
lz4-c                     1.8.1.2              h1de35cc_0
lzo                       2.10                 h362108e_2
markupsafe                1.1.1            py27h1de35cc_0
matplotlib                2.2.3            py27h54f8f79_0
mccabe                    0.6.1                    py27_1
mistune                   0.8.4            py27h1de35cc_0
mkl                       2019.4                      233
mkl-service               2.3.0            py27hfbe908c_0
mkl_fft                   1.0.14           py27h5e564d8_0
mkl_random                1.1.0            py27ha771720_0
mock                      3.0.5                    py27_0
more-itertools            5.0.0                    py27_0
mpc                       1.1.0                h6ef4df4_1
mpfr                      4.0.1                h3018a27_3
mpmath                    1.1.0                    py27_0
msgpack                   0.6.2                    pypi_0    pypi
msgpack-python            0.6.1            py27h04f5b5a_1
multipledispatch          0.6.0                    py27_0
multiprocess              0.70.6.1              py27_1000    conda-forge
navigator-updater         0.2.1                    py27_0
nbconvert                 5.6.0                    py27_1
nbformat                  4.4.0            py27hddc86d0_0
ncurses                   6.1                  h0a44026_1
networkx                  2.2                      py27_1
nltk                      3.4.5                    py27_0
nose                      1.3.7                    py27_2
notebook                  5.7.8                    py27_0
numba                     0.46.0           py27h6440ff4_0
numexpr                   2.7.0            py27h7413580_0
numpy                     1.16.5           py27hacdab7b_0
numpy-base                1.16.5           py27h6575580_0
numpydoc                  0.9.1                      py_0
odo                       0.5.1            py27h992a9f7_0
olefile                   0.46                     py27_0
openpyxl                  2.6.3                      py_0
openssl                   1.1.1d               h1de35cc_3
packaging                 19.2                       py_0
pandas                    0.24.2           py27h0a44026_0
pandoc                    2.2.3.2                       0
pandocfilters             1.4.2                    py27_1
param                     1.9.2                      py_0
parso                     0.5.1                      py_0
partd                     1.0.0                      py_0
path.py                   11.5.0                   py27_0
pathlib2                  2.3.5                    py27_0
pbr                       5.4.3                      py_0
pcre                      8.43                 h0a44026_0
pep8                      1.7.1                    py27_0
pexpect                   4.7.0                    py27_0
pickleshare               0.7.5                    py27_0
pillow                    6.2.0            py27hb68e598_0
pip                       19.1                     pypi_0    pypi
pkginfo                   1.5.0.1                  py27_0
pluggy                    0.13.0                   py27_0
ply                       3.11                     py27_0
portaudio                 19.6.0               h41429eb_1
pox                       0.2.3                      py_1    conda-forge
ppft                      1.6.4.7.1             py27_1000    conda-forge
prometheus-client         0.6.0                    pypi_0    pypi
prometheus_client         0.7.1                      py_0
prompt_toolkit            1.0.15           py27h4a7b9c2_0
psutil                    5.6.3            py27h1de35cc_0
ptyprocess                0.6.0                    py27_0
py                        1.8.0                    py27_0
pyaudio                   0.2.11           py27h1de35cc_1
pycodestyle               2.5.0                    py27_0
pycosat                   0.6.3            py27h1de35cc_0
pycparser                 2.19                     py27_0
pycrypto                  2.6.1            py27h1de35cc_9
pyct                      0.4.6                    py27_0
pycurl                    7.43.0.3         py27ha12b0ac_0
pyflakes                  2.1.1                    py27_0
pygments                  2.4.2                      py_0
pylint                    1.9.2                    py27_0
pymesos                   0.3.9                    pypi_0    pypi
pyodbc                    4.0.27           py27h0a44026_0
pyopenssl                 19.0.0                   py27_0
pyparsing                 2.4.2                      py_0
pyqt                      5.9.2            py27h655552a_2
pyrsistent                0.15.4           py27h1de35cc_0
pysocks                   1.7.1                    py27_0
pytables                  3.5.2            py27h5bccee9_1
pytest                    4.6.2                    py27_0
python                    2.7.17               h97142e2_0
python-dateutil           2.8.0                    py27_0
python.app                2                        py27_9
pytz                      2019.3                     py_0
pyviz_comms               0.7.2                      py_0
pywavelets                1.0.3            py27h1d22016_1
pyyaml                    5.1.1            py27h1de35cc_0
pyzmq                     18.1.0           py27h0a44026_0
qt                        5.9.7                h468cd18_1
qtawesome                 0.6.0                      py_0
qtconsole                 4.5.5                      py_0
qtpy                      1.9.0                      py_0
readline                  7.0                  h1de35cc_5
requests                  2.22.0                   py27_0
rope                      0.14.0                     py_0
ruamel_yaml               0.15.46          py27h1de35cc_0
scandir                   1.10.0           py27h1de35cc_0
scikit-image              0.14.2           py27h0a44026_0
scipy                     1.2.1            py27h1410ff5_0
send2trash                1.5.0                    py27_0
setuptools                41.6.0                   py27_0
simplegeneric             0.8.1                    py27_2
singledispatch            3.4.0.3          py27he22c18d_0
sip                       4.19.8           py27h0a44026_0
six                       1.12.0                   py27_0
snappy                    1.1.7                he62c110_3
snowballstemmer           2.0.0                      py_0
sortedcollections         1.1.2                    py27_0
sortedcontainers          2.1.0                    py27_0
soupsieve                 1.9.3                    py27_0
sphinx                    1.8.5                    py27_0
sphinxcontrib             1.0                      py27_1
sphinxcontrib-websupport  1.1.2                      py_0
spyder                    3.3.6                    py27_0
spyder-kernels            0.5.2                    py27_0
sqlalchemy                1.3.10           py27h1de35cc_0
sqlite                    3.30.1               ha441bb4_0
ssl_match_hostname        3.7.0.1                  py27_0
subprocess32              3.5.4            py27h1de35cc_0
sympy                     1.4                      py27_0
tbb                       2019.8               h04f5b5a_0
tblib                     1.4.0                      py_0
terminado                 0.8.2                    py27_0
testpath                  0.4.2                    py27_0
tk                        8.6.8                ha441bb4_0
toolz                     0.10.0                     py_0
tornado                   5.1.1            py27h1de35cc_0
tqdm                      4.36.1                     py_0
traceback2                1.4.0                    py27_0
traitlets                 4.3.3                    py27_0
typing                    3.7.4.1                  py27_0
unicodecsv                0.14.1           py27h170f95c_0
unittest2                 1.1.0                    py27_0
unixodbc                  2.3.7                h1de35cc_0
urllib3                   1.24.2                   py27_0
wcwidth                   0.1.7            py27h817c265_0
webencodings              0.5.1                    py27_1
werkzeug                  0.16.0                     py_0
wheel                     0.33.6                   py27_0
widgetsnbextension        3.5.1                    py27_0
wrapt                     1.11.2           py27h1de35cc_0
wurlitzer                 1.0.3                    py27_0
xarray                    0.11.3                   pypi_0    pypi
xlrd                      1.2.0                    py27_0
xlsxwriter                1.2.2                      py_0
xlwings                   0.16.0                   py27_0
xlwt                      1.2.0            py27hbeec4ae_0
xz                        5.2.4                h1de35cc_4
yaml                      0.1.7                hc338f04_2
zeromq                    4.3.1                h0a44026_3
zict                      1.0.0                      py_0
zipp                      0.6.0                      py_0
zlib                      1.2.11               h1de35cc_3
zstd                      1.3.7                h5bba6e5_0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
philippjfrcommented, Nov 1, 2019

Oops, totally missed that. The likely cause is that it’s zero range and therefore generates an empty aggregate.

0reactions
jbednarcommented, Nov 6, 2019

I can reproduce the above problem with holoviews.operation.datashader, but it seems to work fine in datashader itself:

import datashader as ds, pandas as pd, datashader.transfer_functions as tf

df = pd.DataFrame(dict(x=[1, 2, 3],y=[3, 3, 3]))
cvs = ds.Canvas(plot_width=200, plot_height=100)
tf.shade(cvs.line(df,x="x",y="y"))

image

The Datashader code involved looks fine to me, in that it checks for the case where min==max and expands the bounds appropriately (datashader/glyphs/glyph.py):

    @staticmethod
    def maybe_expand_bounds(bounds):
        minval, maxval = bounds
        if not (np.isfinite(minval) and np.isfinite(maxval)):
            minval, maxval = -1.0, 1.0
        elif minval == maxval:
            minval, maxval = minval-1, minval+1
        return minval, maxval

But this code isn’t being triggered, because the HoloViews datashader operation takes care of all the ranging itself. So this needs to be fixed on HoloViews, not Datashader.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing Plots — HoloViews v1.15.3
The HoloViews options system allows controlling the various attributes of a plot. While different plotting extensions like bokeh, matplotlib and plotly ...
Read more >
Curve — HoloViews v1.15.3
A Curve is a set of values provided for some set of keys from a continuously indexable 1D coordinate system, where the plotted...
Read more >
holoviews.plotting.bokeh.element
Parameter(default=None, doc=""" Allows to create additional space around the component. May be specified as a two-tuple of the form (vertical, horizontal) ...
Read more >
Plotting with Bokeh — HoloViews v1.15.3
When HoloViews outputs bokeh plots it creates and manipulates bokeh models in the ... It controls both the vertical alignment in a row...
Read more >
Working with Streaming Data — HoloViews v1.15.3
Finally we can clear the data on the stream and plot using the clear method: ... Now you can now easily create an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found