亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

matplotlib 中fill_between

#有換行,黏貼的文本

plt.fill_between(x,x>0,c,c>0.5,color="green")
c,s兩個三角函數
到底怎么填充的啊
我覺得如圖才對

https://img1.sycdn.imooc.com//5b0edd100001d72f04320311.jpg

#下面是代碼

# -*- coding: utf-8 -*-

"""

Spyder Editor

This is a temporary script file.

"""

import numpy as np

import matplotlib.pyplot as plt

plt.title("biao嗯ti")

x=np.linspace(-np.pi,np.pi,256,endpoint=True)

c,s=np.cos(x),np.sin(x)

plt.figure(1)

plt.plot(x,c,label="cos")

plt.plot(x,s,label="sin")

ax=plt.gca()

ax.spines["right"].set_color("none")

ax.spines["top"].set_color("none")

ax.spines["left"].set_position(("data",0))

ax.spines["bottom"].set_position(("data",0))

plt.yticks([1,0.5,0,-0.5,-1])

#plt.xticks([-np.pi,-np.pi/2,0,np.pi/2,np.pi],

# ? ? ? ? ? ["-π","π/2","0","π/2","π"])

plt.legend(loc="upper left")

ax.xaxis.set_ticks_position("bottom")

plt.fill_between(x,x>0,c,c>0.5,color="green")

plt.show()



正在回答

1 回答

plt.fill_between(x,x>0,c,c>0.5,color="green")

#代碼中,x>0是邏輯語言,即在x>0時為真,從橫坐標為1的地方開始填充,x<=0時為假,從橫坐標為0的地方開始填充,其中c為縱坐標約束縱向上的填充范圍(詳細說明見附圖中的黑框范圍和紅色箭頭)。https://img1.sycdn.imooc.com//5b41fd6b000171b504190346.jpg

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

matplotlib 中fill_between

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號