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(x, xmin=1, xmax=-1) comes up empty #13368

Open
ppurka opened this issue Aug 15, 2012 · 27 comments
Open

plot(x, xmin=1, xmax=-1) comes up empty #13368

ppurka opened this issue Aug 15, 2012 · 27 comments

Comments

@ppurka
Copy link
Member

ppurka commented Aug 15, 2012

The following two plots

plot(x, xmin=1, xmax=-1)
plot(x).show(xmin=1, xmax=-1)

give different outputs. In particular, the plot comes up empty in the
former one. This seems to be a conscious decision taken in #5651. The main
line seems to be this line in sage/plot/plot.py and similar lines in
several other files.

    G_kwds = Graphics._extract_kwds_for_show(kwds, ignore=['xmin', 'xmax'])

Is there a reason for this? Should this be "fixed?"

CC: @kcrisman @sagetrac-jakobkroeker @paulmasson @sagetrac-jhonrubia6 @novoselt @alauve @tscrim @jm58660

Component: graphics

Author: Paul Masson

Branch/Commit: u/paulmasson/13368 @ f0eebbb

Reviewer: Javier Honrubia González

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

@kcrisman
Copy link
Member

comment:1

One data point is an email I got today (unrelated to Sage development, just use) asking why

plot(1/x,xmin=-5,xmax=5)

didn't result as expected. So maybe we should do more than ignore them, but raise an error or something...


NO! My belief is that this is a typo. Notice that in #5651, the places where this is ignored are ALL some kind of contour or "rectangular" plot, except for plot.py, but then plot_field.py does not have this, even though it's this kind of plot. In fact, we probably should support things like

sage: plot(x,(x,1,5),xmin=2)

since we might want to keep the data but not show it.

@kcrisman
Copy link
Member

comment:2

Though we'd probably have to deal with

sage: plot(x,(x,1,5),xmin=2).show(xmin=3)

somehow...

@ppurka
Copy link
Member Author

ppurka commented Jun 20, 2013

comment:3

with ymin, the parameter in show overrides the parameter in plot.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@pjbruin
Copy link
Contributor

pjbruin commented Apr 11, 2014

comment:6

An example from #5124 (duplicate of this ticket; note that this was created before #5651):

E = EllipticCurve('37a')
E.plot(xmin=-10, xmax=10)

@ppurka
Copy link
Member Author

ppurka commented Apr 11, 2014

comment:7

I think I had some idea how to fix this. If I get some time I will look at it again. It will not be any time soon, unfortunately. Essentially, we just need to mimic how ymin and ymax are handled.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@kcrisman
Copy link
Member

comment:11

Just came across this again. Really, all relevant options should be passed to show!

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 20, 2016

comment:12

As of 7.3.beta8 evaluating plot(x, xmin=-1, xmax=1) and plot(1/x,xmin=-5,xmax=5,ymin=-5,ymax=5) both produce the expected graphs.

Evaluating plot(x, xmin=1, xmax=-1) with a reversed domain does not produce a plot. Evaluatingplot(1/x,xmin=-5,xmax=5,ymin=5,ymax=-5) with an inverted range flips the plot upside down.

Shouldn't this ticket be first about a sanity check on domain and range? Is there a good reason to allow reversal and inversion?

@paulmasson paulmasson mannequin added the s: needs info label Jul 20, 2016
@ppurka
Copy link
Member Author

ppurka commented Jul 21, 2016

comment:13

Replying to @paulmasson:

Evaluating plot(x, xmin=1, xmax=-1) with a reversed domain does not produce a plot. Evaluatingplot(1/x,xmin=-5,xmax=5,ymin=5,ymax=-5) with an inverted range flips the plot upside down.

Second command should be the desired output.

Shouldn't this ticket be first about a sanity check on domain and range? Is there a good reason to allow reversal and inversion?

A good reason to allow flipped axis is to have axes that are decreasing instead of increasing. It is already possible by using plot(...).show(xmax=-1,xmin=1). This ticket was about making the behavior of plot consistent with what plot(...).show() does.

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 22, 2016

Branch: u/paulmasson/13368

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 22, 2016

Commit: 0f674f2

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 22, 2016

comment:15

He's a solution to this problem. Part of the reason the plots were empty is that the function setup_for_eval_on_grid() in plot/misc.py outputs plotting steps as an absolute value, not a signed value. I've removed that and modified the doctests accordingly, but six other plotting files use that function in addition to plot.py.

All plotting doctests pass and documentation all builds. I scanned all seven plotting documentation HTML files that use setup_for_eval_on_grid() and didn't see anything strange, but other eyes need to look at them closely.

Adding Javier to cc list since he's been working on plotting examples and might spot something wrong.


New commits:

46d5778Pass xmin and xmax to show()
0f674f2Fix doctests after removing 'abs'

@paulmasson paulmasson mannequin modified the milestones: sage-6.4, sage-7.3 Jul 22, 2016
@paulmasson paulmasson mannequin added s: needs review and removed s: needs info labels Jul 22, 2016
@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 24, 2016

comment:19

Andrey, I haven't changed any keywords and don't plan to. All I did was remove abs so that range_steps can take negative as well as positive values. This is necessary for creating plots in plot.py when xmin > xmax.

The question is whether the change of allowing range_steps to be negative will have an unintended impact on other plotting routines. I don't expect you to read all of the plotting code, but if anything else comes to mind let me know. Thanks!

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 18, 2016

Changed commit from 0f674f2 to c3a7f71

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 18, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

c3a7f71Rebase for consistency with #20924

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 18, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

2b85a57Pass xmin and xmax to show()
f0eebbbFix doctests after removing 'abs'

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 18, 2016

Changed commit from c3a7f71 to f0eebbb

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Aug 18, 2016

comment:22

Code rewritten for consistency with #20924

@paulmasson paulmasson mannequin modified the milestones: sage-7.3, sage-7.4 Aug 18, 2016
@sagetrac-jhonrubia6
Copy link
Mannequin

sagetrac-jhonrubia6 mannequin commented Oct 23, 2016

comment:23

everything looks good to me. As I see no negative vote, I'll make it a positive review

@tscrim
Copy link
Collaborator

tscrim commented Oct 23, 2016

comment:24

Reviewer name is needed.

@sagetrac-jhonrubia6
Copy link
Mannequin

sagetrac-jhonrubia6 mannequin commented Oct 23, 2016

Reviewer: Javier Honrubia González

@sagetrac-jhonrubia6 sagetrac-jhonrubia6 mannequin modified the milestones: sage-7.5, sage-7.4 Oct 23, 2016
@vbraun
Copy link
Member

vbraun commented Oct 29, 2016

comment:26
sage -t --long src/sage/schemes/elliptic_curves/ell_generic.py  # 1 doctest failed

see patchbot

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Nov 14, 2016

comment:27

The changes on this ticket produce unexpected results for elliptic curves. Needs to be investigated.

@paulmasson paulmasson mannequin changed the title plot(x, xmax=1, xmin=-1) comes up empty plot(x, xmin=1, xmax=-1) comes up empty Jan 19, 2017
@jm58660
Copy link
Mannequin

jm58660 mannequin commented Jan 23, 2017

comment:30

Maybe not related, but why "e" in "2.717e" in

plot(x/log_b(x, 2), (2.717, 2.72))

@kcrisman
Copy link
Member

comment:31

Maybe not related, but why "e" in "2.717e" in

Indeed unrelated, but also worth a ticket. We don't do a good job dealing with scientific notation that ends up in the tick labels, and you can see that if you try plotting things with really high output values but in a narrow range. For example:

plot(x^2,(x,10^6,10^6+1))

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

10 participants