0

I am working with a dataset in Pandas - Bokeh that has several places where a value is NaN. When making a standard scatter plot, the plotting interface simply leaves out the rows that contain NaN values. However, when I change either axis to log scale, none of the points plot at all. What could be causing this?

1 Answers1

0

This is currently a known issue that is listed as a milestone for version 0.9.4. Check out this thread: https://github.com/bokeh/bokeh/issues/2162

I'm having a similar issue, so as a workaround I have split my ranges by nan values and plotted each set individually. This is based on Bokeh's log scale example and unutbu's answer to this question.

import numpy as np
from bokeh.plotting import figure, output_file, show
from bokeh.models import LogAxis, Range1d

def using_clump(a, b):
    return [a[s] for s in np.ma.clump_unmasked(np.ma.masked_invalid(b))]
def main():
    x = [0.1, 0.5, 1.0, 1.5, np.nan, 2.0, 2.5, 3.0]
    y = [10**xx for xx in x]
    output_file("log.html")

    p = figure(plot_width=400, plot_height=400,
           y_axis_type="log", y_range=(10**-1, 10**4))

    xdata = using_clump(x, x)
    ydata = using_clump(y, x)
    for i in range(0, len(xdata)):
        p.line(xdata[i], ydata[i], line_width=2)
        p.circle(xdata[i], ydata[i], fill_color="white", size=8)

    show(p)

enter image description here

Community
  • 1
  • 1
abe678
  • 99
  • 1
  • 11