Skip to content

Commit

Permalink
Merge pull request #26484 from SamLubelsky/text-backend-plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
sylee957 committed Apr 23, 2024
2 parents ab88a7d + 8757b88 commit 74c56ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sympy/plotting/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def save(self):
def close(self):
pass

def test_basic_plotting_backend():
x = Symbol('x')
plot(x, (x, 0, 3), backend='text')
plot(x**2 + 1, (x, 0, 3), backend='text')

@pytest.mark.parametrize("adaptive", [True, False])
def test_plot_and_save_1(adaptive):
Expand Down
6 changes: 6 additions & 0 deletions sympy/plotting/textplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def textplot_str(expr, a, b, W=55, H=21):
.format(free))
x = free.pop() if free else Dummy()
f = lambdify([x], expr)
if isinstance(a, complex):
if a.imag == 0:
a = a.real
if isinstance(b, complex):
if b.imag == 0:
b = b.real
a = float(a)
b = float(b)

Expand Down

0 comments on commit 74c56ac

Please sign in to comment.