I have a question about the graph of the formula created by SymPy.
Take the following sample code as an example: the first quadrant on a coordinate plane with a primary function and a circle. A total of three fs will be created.
For each region divided by these graphs, for example, take & of three graphs.
Is it possible to draw only specific areas such as Ruru?
If you understand, please advise me.
from sympathy import*
x,y=symbols("xy")
I=(x-30)**2+(y-30)**2-400
J=y+2*x-60
K=(x-10)**2+(y-20)**2-200
p1 = plot_implicit(I,(x,0,100), (y,0,100), show = False, line_color='b')
p2=plot_implicit(J,(x,0,100),(y,0,100), show=False, line_color='b')
p3=plot_implicit(K,(x,0,100), (y,0,100), show=False, line_color='b')
p1.extend(p2)
p1.extend(p3)
p1.show()
SymPy's plot_implicit
fills up the area where giving an inequality to the first argument fills it.In this case, you can specify the AND of the region, such as (I<0)&(J<0)&(K<0)
(Python operator takes precedence over <
and requires parentheses).
from sympathy import*
x,y=symbols("xy")
I=(x-30)**2+(y-30)**2-400
J=y+2*x-60
K=(x-10)**2+(y-20)**2-200
p1=plot_implicit(I,(x,0,100),(y,0,100), show=False, line_color="b")
p2=plot_implicit(J,(x,0,100),(y,0,100), show=False, line_color="b")
p3=plot_implicit(K,(x,0,100), (y,0,100), show=False, line_color="b")
p4=plot_implicit((I<0)&(J<0)&(K<0), (x, 0, 100), (y, 0, 100), show=False, line_color="r")
p1.extend(p2)
p1.extend(p3)
p1.extend(p4)
p1.show()
© 2025 OneMinuteCode. All rights reserved.