问题描述
我绘制了一个指数图,现在我想沿X轴自由移动峰。
中心应该像铃铛,右边应该像我当前的图表,但完全相反。
我该怎么做?
import matplotlib
import math
import numpy as np
matplotlib.use('Agg')
import matplotlib.pyplot as plt
arr_name=[]
arr_value=[]
k=-0.01
for l in range(0,100):
x=pow(k,2)*np.exp(-k*1.8);
if (l%10)==0:
arr_name.append(l/10)
else:
arr_name.append("")
arr_value.append(x)
k=k+0.05
print x
y_pos = np.arange(len(arr_name))
plt.figure(figsize=(8,4))
plt.rcParams.update({'font.size': 8})
plt.subplot(1,1,1)
plt.plot(y_pos,arr_value,'-r')
plt.xticks(y_pos,arr_name)
plt.savefig('/var/www/html/bar/img/test_chart.png')
更新:
可能的解决方案是在图表中心绘制峰值:
for l in range(0,5)*np.exp(-k*1.96);
if (l%10)==0:
arr_name.append(l/10)
else:
arr_name.append("")
arr_value.append(x)
if l>50:
k=k-0.05
else:
k=k+0.05
print x
增加可逆性:
arr_value.reverse()