Hi Thomas,
The patch (or patches) glyph plot polygons. So they can be used to show things like tolerance bands. But you will have to compute the coordinates of the polygon that represents your tolerance band. The reason you need to "reverse" the x coordinates is because polygon coordinates need to form a closed path, and you have to have as many x coordinates as y coordinates Something like:
x -> [0, 1, 2, 3, 3, 2, 1, 1]
y -> [5, 6, 6, 7, 2, 1, 3, 1]
Yes this should be made simpler with the addition of some helper or utility functions that can compute the polygon coords for you, given a path and a tolerance. Things can get a bit more complicated if the resolution of the error results don't exactly match up with the initial path coordinates, etc. Pull requests welcome!!
Thanks
Bryan
···
On May 27, 2014, at 3:22 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 areasareas = 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/f21e64ff-3774-4ff4-b594-609f423e46fc%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.