hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

logx, logy not applying when datashade=True

Open ivirshup opened this issue 5 years ago • 7 comments

When logx or logy is set it doesn't log the points positions if datashade=True, it just changes the scale on the axis. Here's an example for logx:

import pandas as pd
import numpy as np
import holoviews as hv

d = pd.DataFrame({
    "x": np.linspace(1, 100, 10000) + np.random.rand(10000),
    "y": np.linspace(1, 100, 10000) + np.random.rand(10000)
})

(   d.hvplot.scatter("x", "y", logx=True) 
 +  d.hvplot.scatter("x", "y", logx=True, datashade=True)).cols(1)

image

ivirshup avatar Mar 17 '19 03:03 ivirshup

Just ran into the same thing, though I would add that on rescaling the log axis with the zoom tool, the points stick to the extents of the range and don't keep their values relative to that axis:

import pandas as pd
import numpy as np
import hvplot.pandas

df = pd.DataFrame(dict(x=np.arange(1,1000), y=np.arange(1,1000)+np.abs(np.random.randn(999))*100))
df.hvplot.scatter(logy=True)

poplarShift avatar Jun 25 '19 17:06 poplarShift

This is an issue in HoloViews already: https://github.com/pyviz/holoviews/issues/2195 but once it's supported there we will have to fix it here as well.

philippjfr avatar Jul 17 '19 15:07 philippjfr

I think we should just expose the axes options on the rasterize operation in HoloViews and since hvPlot can set the option on the operation and as a plot option we don't have the same issues in hvPlot that we have in HoloViews.

philippjfr avatar Jun 29 '20 16:06 philippjfr

Just ran into the same thing, though I would add that on rescaling the log axis with the zoom tool, the points stick to the extents of the range and don't keep their values relative to that axis:

I can't reproduce that so this must have been fixed upstream. The original issue is still there though.

I think we should just expose the axes options on the rasterize operation in HoloViews and since hvPlot can set the option on the operation and as a plot option we don't have the same issues in hvPlot that we have in HoloViews.

@philippjfr do you mean that the rasterize operation in HoloViews should havelogx and logy as new parameters (and maybe more axes parameters?)?

Also given that https://github.com/holoviz/holoviews/issues/2195 is pretty old and hasn't seen any progress, what do you think about hvPlot raising an error when datashade=True in combination with logx/logy=True?

maximlt avatar Oct 11 '22 11:10 maximlt

I may not remember all the details, but I don't believe that fixing it in hvplot requires solving the underlying HV issue. hvplot can do its own mapping from supplied arguments into arguments for the datashade and rasterize operations, and so it should be able to make this work in hvplot with minimal changes at the hv side (just ensuring that those operations do have the necessary arguments and do pass down their values into datashader). Fixing it in hv would require further mapping from hv options to datashade arguments, which is a much trickier proposition.

jbednar avatar Oct 11 '22 18:10 jbednar

just ensuring that those operations do have the necessary arguments and do pass down their values into datashader

I think I would need more detailed guidance on this. @jlstevens maybe?

maximlt avatar Oct 11 '22 18:10 maximlt

Yes, @jlstevens should be able to give some guidance. A quick check doesn't show any parameters already controlling logx and logy in rasterize or its parent classes AggregationOperation and ResamplingOperation, so those parameters would need to be added, probably to ResamplingOperation, and then passed down into the call to datashader. Once that support is in HoloViews, which seems straightforward, adding it to hvplot should be doable.

jbednar avatar Oct 11 '22 21:10 jbednar