Scatter plot with blank values

I am trying to plot lighting strikes on a scatter graph. It’s working fine with the caveat that it’s plotting a dot at 0 on the Y axis when I want no dot at all, just a blank space.

Here is how I’m building the list:

#Every minute(every time a obs_str comes in), add a blank line to lightning graph
                    if len(yStrikes) == 180:
                    l.writegraph(xStrikes, yStrikes)

And here is the class that is writing out the

 scatter plot:
class LightningGraph :
    def writegraph(self, xAxis, yAxis):
            output_file(filename="/var/www/html/lightning.html", title="Lightning Strikes")
            p = figure(title="Lightning Strikes", y_range=(0,40), x_axis_type="datetime", height=800, width=1400)
            p.scatter(xAxis, yAxis)
            p.xaxis.axis_label="Time Stamp"
            p.yaxis.axis_label="Distance KM"
            p.scatter(xAxis, yAxis)
        except Exception as e:
           raise Exception(e)


What I would like to have happen is those dots on the X axis to disappear and just display nothing if there is no data.

@MABeatty Bokeh just plots what you pass to it. This seems like a purely data preparation / filtering issue. Offhand, you seem to be doing


which is going to be interpreted as zero in the browser, because JavaScript is going to JavaScript. If you don’t want certain points to be shown, this simplest and best thing is to just not add them in the first place. Perhaps you can put a conditional around that code and skip it entirely when you don’t want certain points. Alternatively, you could set the fill_alpha and line_alpha to zero for any points you want to be “in the plot”, but invisible (you’ll need a new array in addition to x, y positions, to store all the alpha values).

But it’s really not actually clear what you are trying to achieve (e.g. what is a “blank line” in the context of a plot?). An image of a correct similar plot for reference would probably go a long way.

Also, unrelated, I can’t think of any reason it would make sense to call p.scatter(xAxis, yAxis) twice in a row with the same arguments.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.