gpt4 book ai didi

python - 改变颜色隐式图

转载 作者:太空狗 更新时间:2023-10-30 00:56:08 24 4
gpt4 key购买 nike

我有以下代码:

import sympy as syp


x, y = syp.symbols('x, y')


Equation_1 = - 2*x + y**2 - 5
Equation_2 = x**3 + syp.sin(y) - 10


syp.plot_implicit(syp.Or(syp.Eq(Equation_1, 0), syp.Eq(Equation_2, 0)), (x, -50, 50), (y, -50, 50))

其中提供了这张图片:

enter image description here

你知道可以用来改变第二条曲线颜色的技巧吗?根据 Sympy 的 documentation,我认为这不是直接可能的.

最佳答案

目前似乎尚未实现将任何类型的颜色参数传递给 plot_implicit 函数。无论您正在绘制多少个函数,都是如此。我怀疑可以添加此功能,但目前还没有。

另一方面,如果您只绘制线条,则可以这样做。方法如下:

import sympy as sy
x = sy.symbols('x')
# Make two plots with different colors.
p1 = sy.plot(x**2, (x, -1, 1), show=False, line_color='b')
p2 = sy.plot(x**3, (x, -1, 1), show=False, line_color='r')
# Make the second one a part of the first one.
p1.extend(p2)
# Display the modified plot object.
p1.show()

A plot of two functions made using SymPy

关于python - 改变颜色隐式图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21429866/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com