我是靠谱客的博主 天真哈密瓜,这篇文章主要介绍python等高线图中添加辅助线_Matplotlib挑战在等高线图中更改线条样式,现在分享给大家,希望可以做个参考。

明白了!在

我用过妈咪蒙面你在哪()函数,如在这段代码中:import numpy as np

import matplotlib.pyplot as plt

from matplotlib import rc

rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})

rc('text', usetex=True)

plt.figure()

plt.ylim([-2,2])

plt.xlim([-0.5,0.5])

lambda_x = np.linspace(-0.5,0.5,1000)

u = np.linspace(-2,2,1000)

X,Y = np.meshgrid(lambda_x,u)

# Drawing f=0 lines for implicit function f(u;lambda) = lambda*u + u**3 - u**5

f1 = X + Y**2 - Y**4

f2 = Y

sigma = X + 3*Y**2 - 5*Y**4

unstable = sigma > 0

stable = sigma < 0

#for i in range(0,10):

#f1[i] = f1[i][stable[i]]

plt.contour(np.ma.masked_where(unstable, X),np.ma.masked_where(unstable, Y), np.ma.masked_where(unstable, f1), levels = [0],colors = ('r'),linewidths = 4,extend='both')

plt.contour(np.ma.masked_where(stable, X),np.ma.masked_where(stable, Y), np.ma.masked_where(stable, f1), levels = [0],colors = ('b'),linewidths = 4,linestyles = 'dashed',extend='both')

plt.contour(np.ma.masked_where(unstable, X),np.ma.masked_where(unstable, Y), np.ma.masked_where(unstable, f2), levels = [0],colors = ('r'),linewidths = 4,extend='both')

plt.contour(np.ma.masked_where(stable, X),np.ma.masked_where(stable, Y), np.ma.masked_where(stable, f2), levels = [0],colors = ('b'),linewidths = 4,linestyles = 'dashed',extend='both')

plt.show()

最后

以上就是天真哈密瓜最近收集整理的关于python等高线图中添加辅助线_Matplotlib挑战在等高线图中更改线条样式的全部内容,更多相关python等高线图中添加辅助线_Matplotlib挑战在等高线图中更改线条样式内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部