Skip to content Skip to sidebar Skip to footer

Fat Band Using Matplotlib In Python

I would like to plot a line with varying thickness using matplotlib in python. To be clearer, I have the following variable import matplotlib.pyplot as P import numpy as N x_valu

Solution 1:

You can do this using fill_between.

For example, to have half the bandwidth above and half below (and also drawing the original line using plot):

enter image description here

import matplotlib.pyplot as P 
import numpy as N

x_value = N.arange(0,10,1)
y_value = N.random.rand(10)
bandwidth = N.random.rand(10)*10print bandwidth
P.fill_between(x_value, y_value+bandwidth/2, y_value-bandwidth/2, alpha=.5)
P.plot(x_value,y_value)
P.show()

Post a Comment for "Fat Band Using Matplotlib In Python"