# [bokeh] Create patches for showing a tolerance band around a graph

Duplicated email, I answered to the previous one… we can continue the discussion there.

···

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

Hey,

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)

line(x,y,color=“black”)

output_file(“sinus_tolerances.html”)

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())

hold(True)

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”)

hold(False)

return areas

areas = markupToleranceArea(x,y,0.05)

show()

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/efd36e37-6caf-4015-bff4-3e22a909f30d%40continuum.io.