我试图绘制一个精确的等高线,如下图左侧的等高线:
https://ars.els-cdn.com/content/image/1-s2.0-S0263224116302147-fx1.jpg
我有一些| Z |样本的数据如下:
https://i.stack.imgur.com/0s9Pw.png
我在这些数据的每个点上都有误差,我只想得到像上面那个一样的轮廓。你知道吗
我正在使用python(bokeh和matplot),但是我找不到以任何方式绘制它的方法。你知道吗
这是我用来绘制数据和误差图的代码(一个简单的bokeh绘图)
import matplotlib as mpl
from bokeh.models import LogColorMapper,ColorMapper,LinearColorMapper, LogTicker, ColorBar
MAG = HoverTool(tooltips=[
("frequency", "$x"),
("Impedance", "@y"),
])
Err = HoverTool(tooltips=[
("frequency", "$x"),
("Error", "@y"),
])
E=zeros(154)
COLORS = Spectral5
#error = (abs(Zc-ZZ)/ZZ)*100
#E=[int(i) for i in error/1000]
for i in range(1):
error=abs(Z[3,:]-Zc[3,:])/Z[3,:]
c = [
"#%02x%02x%02x" % (int(r), int(g), int(b)) for r, g, b, _ in 255*mpl.cm.viridis(mpl.colors.Normalize()(error))
]
mapper = LinearColorMapper(palette="Viridis256", low=0, high=10)
#c={'field': 'y', 'transform': mapper}
p1 = figure(title="Simple test", plot_height=400, plot_width=600 ,x_axis_type="log",y_axis_type="log",tools=['save',MAG,'box_zoom','reset','pan','wheel_zoom'])
p1.circle(f[0,:],Zc[0,:],color=c, size=8,legend="measured")
r1 = p1.line(f[0,:],Z[0,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[1,:],Zc[1,:],color=c, size=8,legend="measured")
r1 = p1.line(f[1,:],Z[1,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[2,:],Zc[2,:],color=c, size=8,legend="measured")
r1 = p1.line(f[2,:],Z[2,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[3,:],Zc[3,:],color=c, size=8,legend="measured")
r1 = p1.line(f[3,:],Z[3,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[4,:],Zc[4,:],color=c, size=8,legend="measured")
r1 = p1.line(f[4,:],Z[4,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[5,:],Zc[5,:],color=c, size=8,legend="measured")
r1 = p1.line(f[5,:],Z[5,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[6,:],Zc[6,:],color=c, size=8,legend="measured")
r1 = p1.line(f[6,:],Z[6,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[7,:],Zc[7,:],color=c, size=8,legend="measured")
r1 = p1.line(f[7,:],Z[7,:], color="black", line_width=1.5,legend="Theortical")
p1.circle(f[8,:],Zc[8,:],color=c, size=8,legend="measured")
r1 = p1.line(f[8,:],Z[8,:], color="black", line_width=1.5,legend="Theortical")
p1.yaxis.axis_label = 'Impedance'
p1.xaxis.axis_label = 'Frequency'
q1 = figure(title="simple line example", plot_height=400, plot_width=600 ,x_axis_type="log",x_range=p1.x_range,tools=[MAG,'box_zoom','reset','pan','wheel_zoom'])
i=0
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=1
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=2
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=3
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=4
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=5
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=6
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=7
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
i=8
error=abs(Z[i,:]-Zc[i,:])/Z[i,:]
rr1 = q1.circle(f[i,:],error, color=c, line_width=3)
color_bar = ColorBar(color_mapper=mapper,
label_standoff=12, border_line_color=None, location=(0,0))
show(列(p1,q1),notebook\u handle=True)
目前没有回答
相关问题 更多 >
编程相关推荐