how to plot the points of a set of integers on a number line graph of a one-variable linear equation

Question:

I’m new to sympy plotting, I’ve searched through google browser and stackoverflow, but can’t find how to plot the point of a set of integers on a number line graph of a one variable linear equation. Can anyone help me with this problem of mine?

This is my code:

from sympy import symbols, plot
from sympy.plotting import plot 
from sympy import *
x = symbols("x")
init_printing(use_unicode=True)
ekpr =  Eq(4*(2*x + 3), 10*x + 8)
pprint(ekpr)
sol = solve(ekpr, x)
print(sol)
plot((x), xlim=[-5,7], ylim=[3, 2])

The results are as follows:

1

While I want a number line that points to the number
2

like the following image:

3

Asked By: Fahrizal

||

Answers:

You’d have to use the marker keyword argument, which is poorly documented. Here is how:

plot(
    ekpr.rewrite(Add), (x, -5, 7),
    markers=[{
        "args": [sol, [0]], # coordinates of the point
        "marker": "o" # the type of marker to use
    }]
)

enter image description here

Answered By: Davide_sd
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.