[bokeh] patches creation hard to understand - how to return custom x range?

The structure seems hard to understand, can’t this be done in a more simple way?

Did you check the bollinger band example? I think it can help you with this “tolerance” thing: https://github.com/ContinuumIO/bokeh/blob/master/examples/plotting/file/bollinger.py


On Tue, May 27, 2014 at 5:22 AM, Thomas Rusche [email protected] wrote:


how can you make a tolerance band around a graph?

My custom graph is a sinus curve from 0 to 2*pi (=12 round about)

I customized the brewer example from here: http://bokeh.pydata.org/docs/gallery/brewer.html

However the patches return not the same x range.

Where does the x2 come from? It is a fix name for whatever and comes out off nowwhere.

And why do I need to reverse one x-range?

However, how can I fit the patches to my curve? To check what the program does, i printed x2 and the list of areavalues.

The structure seems hard to understand, can’t this be done in a more simple way?

from collections import OrderedDict

import numpy as np

import pandas as pd

from bokeh.plotting import *

N = 100

pi = 3.14159

x = np.linspace(0,4*pi,N)

print x

y = np.sin(x)



def markupToleranceArea(x, y, tolerance):

data = {}

N = len(y)

data[‘x’] = x

data[‘y’] = y

data[‘yLowerTol’] = y * (1-tolerance)

data[‘yUpperTol’] = y * (1+tolerance)

areas = OrderedDict()

markupFrom = data[‘yLowerTol’][::-1]

markupTo = data[‘yUpperTol’]

areas[‘markedUp’] = np.hstack((markupFrom, markupTo))

print len(areas[‘markedUp’])

for a in areas:

print x2

print list(areas.values())


line(x,y,color=“black”) #Graph, from which the tolerance should be plotted.

patches([x2 for a in areas], list(areas.values()), color=“lightgrey”, alpha=0.5, line_color=“grey”)


return areas

areas = markupToleranceArea(x,y,0.05)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/f21e64ff-3774-4ff4-b594-609f423e46fc%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.