Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot correctly up to asymptotes #3907

Closed
kcrisman opened this issue Aug 20, 2008 · 7 comments
Closed

plot correctly up to asymptotes #3907

kcrisman opened this issue Aug 20, 2008 · 7 comments

Comments

@kcrisman
Copy link
Member

Assuming this is a bug, not a feature:

sage: plot(1/x,0,1)
<boom>

My feeling is this should plot okay, since there is only one "bad"
point and the plotting code handles that kind of thing.

As far as I can tell from the traceback (relevant appended), the
problem is in the axes, which convert (at least when using
_tasteful_ticks) the endpoints to integers, given a big enough range.

sage: plot(1/x,0,1)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call
last)

/Applications/sage/local/lib/python2.5/site-packages/sage/plot/plot.py
in _repr_(self)
    738         """
    739         if SHOW_DEFAULT:
--> 740             self.show()
    741             return ''
    742         else:

/Applications/sage/local/lib/python2.5/site-packages/sage/plot/plot.py
in show(self, xmin, xmax, ymin, ymax, figsize, filename, dpi, axes,
axes_labels, frame, fontsize, aspect_ratio)
   1252                   axes_labels=axes_labels,
   1253                   frame=frame, fontsize=fontsize,
-> 1254                   aspect_ratio=aspect_ratio)
   1255         os.system('%s %s 2>/dev/null 1>/dev/null &'%
(sage.misc.viewer.browser(), filename))
   1256

/Applications/sage/local/lib/python2.5/site-packages/sage/plot/plot.py
in save(self, filename, xmin, xmax, ymin, ymax, figsize, figure, sub,
savenow, dpi, axes, axes_labels, fontsize, frame, verify,
aspect_ratio)
   1429                 xmin,xmax,ymin,ymax = self._prepare_axes(xmin,
xmax, ymin, ymax)
   1430
-> 1431                 xmin, xmax, ymin, ymax =
sage_axes.add_xy_axes(subplot, xmin, xmax, ymin, ymax)
   1432
   1433                 subplot.set_xlim(xmin, xmax)

/Applications/sage/local/lib/python2.5/site-packages/sage/plot/axes.py
in add_xy_axes(self, subplot, xmin, xmax, ymin, ymax, axes, ticks,
axesstyle, axes_labels)
    324
    325         #evalute find_axes for y values and x ticks
--> 326         x_axis_ypos, ystep, ytslminor, ytslmajor =
self._find_axes(ymin, ymax)
    327         xltheight = 0.015*yspan
    328         xstheight = 0.25*xltheight

/Applications/sage/local/lib/python2.5/site-packages/sage/plot/axes.py
in _find_axes(self, minval, maxval)
    240             tslmajor, oppaxis, step =
self._tasteless_ticks(minval, maxval, 10)
    241         else:
--> 242             tslmajor, oppaxis, step =
self._tasteful_ticks(minval, maxval)
    243         min = tslmajor[0] - step
    244         tslminor = sage.misc.misc.srange(min, maxval +
0.2*step, 0.2*step)

/Applications/sage/local/lib/python2.5/site-packages/sage/plot/axes.py
in _tasteful_ticks(self, minval, maxval)
    124             else:
    125                 if maxval >= 10:
--> 126                     sl = [s for s in str(int(absmax))]
    127                     d0 = eval(sl[0])
    128                     d1 = eval(sl[1])

OverflowError: cannot convert float infinity to long

Component: graphics

Issue created by migration from https://trac.sagemath.org/ticket/3907

@mwhansen
Copy link
Contributor

Attachment: trac_3907.patch.gz

@mwhansen
Copy link
Contributor

comment:1

I've attached a patch which fixes the big traceback you get and actually produces a plot. This, however, does not fix the issue with the range on the y-axis being thrown of by asymptotes. I think that should be a separate ticket.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Aug 29, 2008

comment:2

Replying to @mwhansen:

I've attached a patch which fixes the big traceback you get and actually produces a plot. This, however, does not fix the issue with the range on the y-axis being thrown of by asymptotes. I think that should be a separate ticket.

kcrisman opened a ticket for that at #3985 - at least it seems very close to what you suggest.

Cheers,

Michael

@robertwb
Copy link
Contributor

robertwb commented Sep 2, 2008

comment:3

Mostly looks good, but what about -inf?

@mwhansen
Copy link
Contributor

mwhansen commented Sep 5, 2008

comment:4

Attachment: trac_3907.2.patch.gz

I've updated the patch to handle the -inf case.

@rlmill
Copy link
Mannequin

rlmill mannequin commented Sep 5, 2008

comment:5

Apply only the second patch- applies cleanly to sage-3.1.2.alpha3 and passes tests in the files it touches.

@rlmill rlmill mannequin added the s: positive review label Sep 5, 2008
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Sep 6, 2008

comment:6

Merged in Sage 3.1.2.rc0

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Sep 6, 2008
@rlmill rlmill mannequin mentioned this issue Sep 5, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants