holoviz / datashader

Quickly and accurately render even the largest data.
http://datashader.org
BSD 3-Clause "New" or "Revised" License
3.24k stars 363 forks source link

Datashader almost handles logarithmic axes in MPL #297

Open StevenCHowell opened 7 years ago

StevenCHowell commented 7 years ago

I want to use Datashader to plot tens of thousands of lines on a log-log plot using MPL. I copied @tacaswell's code from PR #200, replacing cvs.points with cvs.lines, and formatted my data in a DataFrame, as discussed in issue #286.

I was pleased that when I designated my MPL axes to be logarithmic

ax2.set_xscale("log", nonposx='clip')
ax2.set_yscale("log", nonposy='clip')

Datashader did output the result on the correct scale. Unfortunately, there is an artificial stair step behavior. I am not certain the cause but it seems like the pixels were binned on a linear scale, then transformed to a logarithmic scale.

Here is the result when using log scale test_log

and here is the result when I simply take the log10 of the data before passing it to Datashader test

I want to have the plots from the second version, but with the labels from the first version. Any ideas how to do this?

jbednar commented 7 years ago

Have you tried setting x_axis_type='log' and y_axis_type='log' in the call to Canvas?

tacaswell commented 7 years ago

Unfortunately, there is an artificial stair step behavior. I am not certain the cause but it seems like the pixels were binned on a linear scale, then transformed to a logarithmic scale.

That is exactly what is happening! Working around this will be interesting, a feature in 2.0 is AxesImage now correctly respects the scales.

I suspect that there just needs to be a cut-out only use the affine part of the data transform, but not sure exactly where that cut-out should be.