Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将轴限制设置为围绕matplotlib中的点对称?_Python_Matplotlib - Fatal编程技术网

Python 如何将轴限制设置为围绕matplotlib中的点对称?

Python 如何将轴限制设置为围绕matplotlib中的点对称?,python,matplotlib,Python,Matplotlib,是否有可以在matplotlib中设置的选项,以便轴限制始终围绕给定值对称 像这样的东西 import numpy as np import matplotlib.pyplot as plt x = np.arange(10) y = np.random.uniform(0,1,10) center = 0.5 maxdiff = np.max(np.abs(y-center)) ymin = center-maxdiff - 0.1 ymax = center+maxdiff + 0

是否有可以在matplotlib中设置的选项,以便轴限制始终围绕给定值对称

像这样的东西

import numpy as np
import matplotlib.pyplot as plt


x = np.arange(10)
y = np.random.uniform(0,1,10)

center = 0.5

maxdiff = np.max(np.abs(y-center))

ymin = center-maxdiff - 0.1
ymax = center+maxdiff + 0.1



fig,ax = plt.subplots()
plt.plot(x,y)
ax.set_ylim(ymin,ymax)
但当我添加新数据时,限制会自动调整吗