python - how to magnify a peak in matplotlib? -


i have relatively simple problem. have set of data has peak in position. plot more clear, want multiply data around peak. how so? example, multiply values between 11 < x < 17 (which has has y > -0.1) factor of 2. in real data have condition on y-value e.g y > y0.

import numpy np import matplotlib.pyplot plt  x = np.linspace(1, 20, 100) y = np.sin(x)/x  plt.plot(x,y,'-ob',lw=2,markersize=12)  plt.show() 

thank in advance!

i'm not sure you're trying accomplish, can use np.where select specific indexes in array, correspond conditional (i.e. 11<x<20).

http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html

import numpy np import matplotlib.pyplot plt  x = np.linspace(1, 20, 100) y = np.sin(x)/x  plt.plot(x, y, '-ob', lw=2, markersize=12)  = np.where( (x>11) & (x<20) & (y>-0.1))   y[i]*=2  plt.plot(x, y, 'g', lw=2) plt.show() 

edit
also, see @hitzg comment directly creating binary mask. therefore code can shortened to:

y[(x>11) & (x<20) & (y>-0.1)]*=2 

enter image description here


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -