Re: [sage-support] bug in plot?

2024-03-16 Thread kcrisman


I'd think that matplotlib's defaults are defaults for a good reason.


Agreed, but not a good *mathematical* reason. It is a good *data analysis* 
reason (appropriate for mpl), which is not the same thing.  I can't think 
of a single mathematics textbook, talk, or other purely mathematical 
setting in which I've ever seen an offset of that type.  Axes are always 
when the variables = 0, end of story.
 

I'd rather add a note in the docs saying how to change this option.



Naturally, we can do that anyway, and in fact should include several 
examples of the type of usage where that would be helpful. 

Nonetheless, especially since Sage does not seem to be used very heavily 
for data applications (pandas, numpy, or others long since filling that 
gap), I would also recommend changing that default.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/95d368bb-9fb3-42ec-b1d5-96fe457f790bn%40googlegroups.com.


Re: [sage-support] bug in plot?

2024-03-16 Thread Dima Pasechnik
On Fri, Mar 15, 2024 at 9:44 PM Nils Bruin  wrote:

> On Friday 15 March 2024 at 12:42:49 UTC-7 kcrisman wrote:
>
> Or rather, should the default be useoffset False?
>
>
> Yes, I think that would be reasonable to do. Clearly, offsets being used
> without the user knowing they exist can easily lead to confusion and
> misinterpreting the graph, as had been demonstrated here. With the default
> off, the user would get an ugly graph. If they want to improve it, they
> would hopefully read the documentation. If we document "useoffset" then the
> user could find it there.
>

I'd think that matplotlib's defaults are defaults for a good reason.
I'd rather add a note in the docs saying how to change this option.


> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-support/24d2b075-0b6f-40f2-8170-67d7a2b36c36n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq1Ov9bZ52g56qJ_HbV%2B6SuhroQ6Z0k8%3DPN7J0aNoBMt0w%40mail.gmail.com.


Re: [sage-support] bug in plot?

2024-03-15 Thread Nils Bruin
On Friday 15 March 2024 at 12:42:49 UTC-7 kcrisman wrote:

Or rather, should the default be useoffset False?


Yes, I think that would be reasonable to do. Clearly, offsets being used 
without the user knowing they exist can easily lead to confusion and 
misinterpreting the graph, as had been demonstrated here. With the default 
off, the user would get an ugly graph. If they want to improve it, they 
would hopefully read the documentation. If we document "useoffset" then the 
user could find it there.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/24d2b075-0b6f-40f2-8170-67d7a2b36c36n%40googlegroups.com.


Re: [sage-support] bug in plot?

2024-03-15 Thread Dima Pasechnik



On 15 March 2024 19:42:48 GMT, kcrisman  wrote:
>
>
>it's not a bug, it's a feature. :-)
>https://discourse.matplotlib.org/t/default-format-of-axis-offset-label/23162/2
>
>
>Correct.
>
>import matplotlib as mpl
>mpl.rcParams['axes.formatter.useoffset'] = False
>plot((x^2+0.0001)/(x^2+0.000101), (x,-0.1,0.1))
>
>produces the normal labelling of y-axes, without an offset.
>Perhaps we should have an example like this in the manual.
>
>
>
>Or rather, should the default be useoffset False? 

the reason matplotlib uses it is to reduce the clutter
large numbers next to the y-axis may produce if their common messy offset is 
not taken into account.



I would say that for teaching purposes it might be set to off, but otherwise it 
might be useful to have it on.


>  We already change one of 
>the defaults in https://github.com/sagemath/sage/pull/37502 and I wonder 
>how often people are seeing this offset; I've personally never seen it 
>actually show up before, but maybe it's more common than we think.  Has 
>anyone seen it on ask.sagemath?
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/BD475490-570D-4895-8AB3-1C8AAA27A450%40gmail.com.


Re: [sage-support] bug in plot?

2024-03-15 Thread kcrisman


it's not a bug, it's a feature. :-)
https://discourse.matplotlib.org/t/default-format-of-axis-offset-label/23162/2


Correct.

import matplotlib as mpl
mpl.rcParams['axes.formatter.useoffset'] = False
plot((x^2+0.0001)/(x^2+0.000101), (x,-0.1,0.1))

produces the normal labelling of y-axes, without an offset.
Perhaps we should have an example like this in the manual.



Or rather, should the default be useoffset False?  We already change one of 
the defaults in https://github.com/sagemath/sage/pull/37502 and I wonder 
how often people are seeing this offset; I've personally never seen it 
actually show up before, but maybe it's more common than we think.  Has 
anyone seen it on ask.sagemath?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/423463e3-f522-46ca-8703-810f49e1e475n%40googlegroups.com.


Re: [sage-support] bug in plot?

2024-03-15 Thread Dima Pasechnik
On Fri, Mar 15, 2024 at 9:13 AM David Joyner  wrote:

>
>
> On Thu, Mar 14, 2024 at 8:17 PM Dima Pasechnik  wrote:
>
>>
>>
>> On Fri, Mar 15, 2024 at 12:15 AM Dima Pasechnik 
>> wrote:
>>
>>>
>>>
>>> On Thu, Mar 14, 2024 at 9:32 PM Dima Pasechnik 
>>> wrote:
>>>


 On 14 March 2024 21:09:22 GMT, Nils Bruin  wrote:
 >I get the impression that without setting ymin,ymax you just end up
 with a
 >tiny range for the y-axis and its labelling is just very weird. I
 think the
 >labels displayed are shifted and scaled. So the error is just how the
 >labels are printed. That looks the same as
 >https://github.com/sagemath/sage/issues/34233
 >

 Good catch! So it seems indeed the same story, just on the microscale.
 With the patch from #34233 I get essentially the same graph, but with extra
 10^-9
 or something like this printed above the graph.
 So when x is very close to 0 one indeed sees this "sharp" drop, by 10^9
 or something...

 >The default behaviour would be to derive ymin and ymax from the
 sampled
 >points, and in your point plot example, those values vary from 1-1e-6
 to
 >1+0e-6. So I think the range is derived appropriately. The labels on
 the
 >y-axis are just printed in a misguided way.

>>>
>>> Attached in the plot with x in [-0.1,0.1] - and it is actually OK, I
>>> think the minimum (with x=0) is where it should be, at 0.990...
>>>
>> I meant  0.990 x 10^-6, as indicated on the label.
>>
>
> That's good news, that it's just a matplotlib bug in the labeling of the
> y-axis in the default case.
>

it's not a bug, it's a feature. :-)
https://discourse.matplotlib.org/t/default-format-of-axis-offset-label/23162/2

indeed,


import matplotlib as mpl
mpl.rcParams['axes.formatter.useoffset'] = False
plot((x^2+0.0001)/(x^2+0.000101), (x,-0.1,0.1))

produces the normal labelling of y-axes, without an offset.
Perhaps we should have an example like this in the manual.


HTH
Dima



>
> Thanks everyone!
>
>
>>
>> It's a bit  confusing that the y-axis is labelled this way, but the
>>> offset of +1 is indicated at the
>>> label above.
>>>
>>> Dima
>>>
>>>
 >

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "sage-support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sage-support+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sage-support/CAAWYfq2qWATF3Jkx_RjvF_BeK1tOD_ge3kUV7eNFtTtm8oK8qg%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-support/CAEQuuAW6GJUaeJYds-sSJ4qktrid0U5Hn%2ByKdV684MUBWb6z6Q%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq12aJ370ymT6%2BS-o4xgLsb_sp94aXrgGpLXyYdDgnTWUw%40mail.gmail.com.


Re: [sage-support] bug in plot?

2024-03-15 Thread David Joyner
On Thu, Mar 14, 2024 at 8:17 PM Dima Pasechnik  wrote:

>
>
> On Fri, Mar 15, 2024 at 12:15 AM Dima Pasechnik  wrote:
>
>>
>>
>> On Thu, Mar 14, 2024 at 9:32 PM Dima Pasechnik  wrote:
>>
>>>
>>>
>>> On 14 March 2024 21:09:22 GMT, Nils Bruin  wrote:
>>> >I get the impression that without setting ymin,ymax you just end up
>>> with a
>>> >tiny range for the y-axis and its labelling is just very weird. I think
>>> the
>>> >labels displayed are shifted and scaled. So the error is just how the
>>> >labels are printed. That looks the same as
>>> >https://github.com/sagemath/sage/issues/34233
>>> >
>>>
>>> Good catch! So it seems indeed the same story, just on the microscale.
>>> With the patch from #34233 I get essentially the same graph, but with extra
>>> 10^-9
>>> or something like this printed above the graph.
>>> So when x is very close to 0 one indeed sees this "sharp" drop, by 10^9
>>> or something...
>>>
>>> >The default behaviour would be to derive ymin and ymax from the sampled
>>> >points, and in your point plot example, those values vary from 1-1e-6
>>> to
>>> >1+0e-6. So I think the range is derived appropriately. The labels on
>>> the
>>> >y-axis are just printed in a misguided way.
>>>
>>
>> Attached in the plot with x in [-0.1,0.1] - and it is actually OK, I
>> think the minimum (with x=0) is where it should be, at 0.990...
>>
> I meant  0.990 x 10^-6, as indicated on the label.
>

That's good news, that it's just a matplotlib bug in the labeling of the
y-axis in the default case.

Thanks everyone!


>
> It's a bit  confusing that the y-axis is labelled this way, but the offset
>> of +1 is indicated at the
>> label above.
>>
>> Dima
>>
>>
>>> >
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-support/CAAWYfq2qWATF3Jkx_RjvF_BeK1tOD_ge3kUV7eNFtTtm8oK8qg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAEQuuAW6GJUaeJYds-sSJ4qktrid0U5Hn%2ByKdV684MUBWb6z6Q%40mail.gmail.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread Dima Pasechnik
On Fri, Mar 15, 2024 at 12:15 AM Dima Pasechnik  wrote:

>
>
> On Thu, Mar 14, 2024 at 9:32 PM Dima Pasechnik  wrote:
>
>>
>>
>> On 14 March 2024 21:09:22 GMT, Nils Bruin  wrote:
>> >I get the impression that without setting ymin,ymax you just end up with
>> a
>> >tiny range for the y-axis and its labelling is just very weird. I think
>> the
>> >labels displayed are shifted and scaled. So the error is just how the
>> >labels are printed. That looks the same as
>> >https://github.com/sagemath/sage/issues/34233
>> >
>>
>> Good catch! So it seems indeed the same story, just on the microscale.
>> With the patch from #34233 I get essentially the same graph, but with extra
>> 10^-9
>> or something like this printed above the graph.
>> So when x is very close to 0 one indeed sees this "sharp" drop, by 10^9
>> or something...
>>
>> >The default behaviour would be to derive ymin and ymax from the sampled
>> >points, and in your point plot example, those values vary from 1-1e-6 to
>> >1+0e-6. So I think the range is derived appropriately. The labels on the
>> >y-axis are just printed in a misguided way.
>>
>
> Attached in the plot with x in [-0.1,0.1] - and it is actually OK, I think
> the minimum (with x=0) is where it should be, at 0.990...
>
I meant  0.990 x 10^-6, as indicated on the label.

It's a bit  confusing that the y-axis is labelled this way, but the offset
> of +1 is indicated at the
> label above.
>
> Dima
>
>
>> >
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq2qWATF3Jkx_RjvF_BeK1tOD_ge3kUV7eNFtTtm8oK8qg%40mail.gmail.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread Dima Pasechnik
On Thu, Mar 14, 2024 at 9:32 PM Dima Pasechnik  wrote:

>
>
> On 14 March 2024 21:09:22 GMT, Nils Bruin  wrote:
> >I get the impression that without setting ymin,ymax you just end up with
> a
> >tiny range for the y-axis and its labelling is just very weird. I think
> the
> >labels displayed are shifted and scaled. So the error is just how the
> >labels are printed. That looks the same as
> >https://github.com/sagemath/sage/issues/34233
> >
>
> Good catch! So it seems indeed the same story, just on the microscale.
> With the patch from #34233 I get essentially the same graph, but with extra
> 10^-9
> or something like this printed above the graph.
> So when x is very close to 0 one indeed sees this "sharp" drop, by 10^9 or
> something...
>
> >The default behaviour would be to derive ymin and ymax from the sampled
> >points, and in your point plot example, those values vary from 1-1e-6 to
> >1+0e-6. So I think the range is derived appropriately. The labels on the
> >y-axis are just printed in a misguided way.
>

Attached in the plot with x in [-0.1,0.1] - and it is actually OK, I think
the minimum (with x=0) is where it should be, at 0.990...
It's a bit  confusing that the y-axis is labelled this way, but the offset
of +1 is indicated at the
label above.

Dima


> >
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq07qqO1ce3--w7WbwJyLvRM_o%2BVdQ-%2BbShRK%2Bg_ZsZ5NA%40mail.gmail.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread Dima Pasechnik



On 14 March 2024 21:09:22 GMT, Nils Bruin  wrote:
>I get the impression that without setting ymin,ymax you just end up with a 
>tiny range for the y-axis and its labelling is just very weird. I think the 
>labels displayed are shifted and scaled. So the error is just how the 
>labels are printed. That looks the same as 
>https://github.com/sagemath/sage/issues/34233
>

Good catch! So it seems indeed the same story, just on the microscale. With the 
patch from #34233 I get essentially the same graph, but with extra 10^-9 
or something like this printed above the graph.
So when x is very close to 0 one indeed sees this "sharp" drop, by 10^9 or 
something...

>The default behaviour would be to derive ymin and ymax from the sampled 
>points, and in your point plot example, those values vary from 1-1e-6 to 
>1+0e-6. So I think the range is derived appropriately. The labels on the 
>y-axis are just printed in a misguided way.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/2E7ABEB6-6743-4EFF-AF68-3A4A4DD5E4E1%40gmail.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread Nils Bruin
I get the impression that without setting ymin,ymax you just end up with a 
tiny range for the y-axis and its labelling is just very weird. I think the 
labels displayed are shifted and scaled. So the error is just how the 
labels are printed. That looks the same as 
https://github.com/sagemath/sage/issues/34233

The default behaviour would be to derive ymin and ymax from the sampled 
points, and in your point plot example, those values vary from 1-1e-6 to 
1+0e-6. So I think the range is derived appropriately. The labels on the 
y-axis are just printed in a misguided way.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/469759c8-09a9-4b61-aa1c-aeda68bdbc7dn%40googlegroups.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread David Joyner
On Thu, Mar 14, 2024 at 10:35 AM Dima Pasechnik  wrote:

> It might help seeing your graphs here, too.
>

It is attached, Dima. Note that the correct graph should be
(for all practical purposes) simply the plot of the constant
function 1 for all x.


[image: bug-in-plot-of-rational-function.jpg]


> On Thu, Mar 14, 2024 at 10:04 AM David Joyner  wrote:
>
>> Hi:
>>
>> I'm trying to show my students a plot of
>> a rational function whose graph is basically 1,
>> so I plotted
>> f(x) = (x^2+0.0001)/(x^2+0.000101)
>> However, there is a problem: Note the difference between
>> plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10))
>> (which dips down near x=0) and
>> plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10), ymin = -0.1, ymax = 1.5
>> )
>> (which basically looks like a straight line).
>> Same problem for lists:
>>
>> sage: L = [(x/100, f(x/100)) for x in range(-100, 100)]
>> sage: list_plot(L)  # bug?
>> sage: list_plot(L, ymin=-0.5, ymax=1.5) # good
>>
>> This is using 'SageMath version 10.3.rc1, Release Date: 2024-02-29' on
>> an ubuntu machine. Can anyone tell what is going on here? I'm happy to
>> attached jpgs of the plots I get, if desired.
>>
>> For comparison, it appears that Sympy plots this correctly.
>>
>> - David Joyner
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sage-support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sage-support+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sage-support/CAEQuuAXPcQ6_g67a7L4bdy1Ko%2BFH1VnHAT25G3LfY6XR1mMaEg%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-support/CAAWYfq1DheVMU-33w7uvSFn1HrtWqrNWT4ciH6W3AtvF-J4_jw%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAEQuuAXj-9NV-AWw0BJY7kFVRYQhP-LbAW3ikh%3D88_y6zFQnLA%40mail.gmail.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread David Joyner
On Thu, Mar 14, 2024 at 1:51 PM kcrisman  wrote:

>
>
> On Thursday, March 14, 2024 at 10:35:50 AM UTC-4 dim...@gmail.com wrote:
>
> It might help seeing your graphs here, too.
>
>
> Try this:
>
>
> https://sagecell.sagemath.org/?z=eJxL06jQVLBV0KiIM9I20DMwMDDU1EfiGBiAhXi5fICKojUq9IEiOgppEIampkJafpFChUJmnkJRYl56qoYuWBokFcvLlZNZXBJfkJNfouGjqYAVKCsklabb83IpIynVUajMzcyz1TXQMwUxEytsDfVMNYFK0_PzUwDaYipb=sage=eJyLjgUAARUAuQ==
>
>
That's the list plot I get as well, thanks Karl!
I'm confused why adding the ymin and ymax optional arguments fixes the
problem. They seem like independent behaviors.

Also, I spoke too soon about it working on Sympy. I simply tried the Live
Sympy cell online with the default arguments, where it does work.
However, if you use sympy on the command line, it seems to have the same
sort of bug. Your suggestion below suggests it is an upstream
bug in matplotlib, right?

Notice the label 1e-6 + 1, the offset option for matplotlib.  I'm surprised
> that's showing up here for the first time, I don't recall that showing up
> before, but as we've noted at #34233 there were changes a while back in mpl
> that our code failed to keep up with.
>
> One thing one could try, then, is to add, in addition to the
>
> rcParams['axes.formatter.use_mathtext'] = True
>
> at #34233 is to see whether one of these (or whatever the right syntax is)
> might help:
>
> rcParams['axes.formatter.use_offSet'] = False
> rcParams["axes.formatter.offset_threshold"]
>
>
> On Thu, Mar 14, 2024 at 10:04 AM David Joyner  wrote:
>
> Hi:
>
> I'm trying to show my students a plot of
> a rational function whose graph is basically 1,
> so I plotted
> f(x) = (x^2+0.0001)/(x^2+0.000101)
> However, there is a problem: Note the difference between
> plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10))
> (which dips down near x=0) and
> plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10), ymin = -0.1, ymax = 1.5)
> (which basically looks like a straight line).
> Same problem for lists:
>
> sage: L = [(x/100, f(x/100)) for x in range(-100, 100)]
> sage: list_plot(L)  # bug?
> sage: list_plot(L, ymin=-0.5, ymax=1.5) # good
>
> This is using 'SageMath version 10.3.rc1, Release Date: 2024-02-29' on an
> ubuntu machine. Can anyone tell what is going on here? I'm happy to
> attached jpgs of the plots I get, if desired.
>
> For comparison, it appears that Sympy plots this correctly.
>
> - David Joyner
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-support/CAEQuuAXPcQ6_g67a7L4bdy1Ko%2BFH1VnHAT25G3LfY6XR1mMaEg%40mail.gmail.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-support/6e860869-43e0-48fe-b25d-805edfdf98a7n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAEQuuAVjXjSDX2yNUdnT_W4faSRGKJ9bdRV3ad6trMP2Q3N96g%40mail.gmail.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread kcrisman


On Thursday, March 14, 2024 at 10:35:50 AM UTC-4 dim...@gmail.com wrote:

It might help seeing your graphs here, too.


Try this:

https://sagecell.sagemath.org/?z=eJxL06jQVLBV0KiIM9I20DMwMDDU1EfiGBiAhXi5fICKojUq9IEiOgppEIampkJafpFChUJmnkJRYl56qoYuWBokFcvLlZNZXBJfkJNfouGjqYAVKCsklabb83IpIynVUajMzcyz1TXQMwUxEytsDfVMNYFK0_PzUwDaYipb=sage=eJyLjgUAARUAuQ==

Notice the label 1e-6 + 1, the offset option for matplotlib.  I'm surprised 
that's showing up here for the first time, I don't recall that showing up 
before, but as we've noted at #34233 there were changes a while back in mpl 
that our code failed to keep up with.

One thing one could try, then, is to add, in addition to the 

rcParams['axes.formatter.use_mathtext'] = True

at #34233 is to see whether one of these (or whatever the right syntax is) 
might help:

rcParams['axes.formatter.use_offSet'] = False
rcParams["axes.formatter.offset_threshold"]
 

On Thu, Mar 14, 2024 at 10:04 AM David Joyner  wrote:

Hi:

I'm trying to show my students a plot of
a rational function whose graph is basically 1,
so I plotted 
f(x) = (x^2+0.0001)/(x^2+0.000101)
However, there is a problem: Note the difference between 
plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10))
(which dips down near x=0) and
plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10), ymin = -0.1, ymax = 1.5)
(which basically looks like a straight line).
Same problem for lists:

sage: L = [(x/100, f(x/100)) for x in range(-100, 100)] 
sage: list_plot(L)  # bug?
sage: list_plot(L, ymin=-0.5, ymax=1.5) # good

This is using 'SageMath version 10.3.rc1, Release Date: 2024-02-29' on an 
ubuntu machine. Can anyone tell what is going on here? I'm happy to 
attached jpgs of the plots I get, if desired.

For comparison, it appears that Sympy plots this correctly.

- David Joyner


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to sage-support...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAEQuuAXPcQ6_g67a7L4bdy1Ko%2BFH1VnHAT25G3LfY6XR1mMaEg%40mail.gmail.com
 

.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/6e860869-43e0-48fe-b25d-805edfdf98a7n%40googlegroups.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread Dima Pasechnik
It might help seeing your graphs here, too.

On Thu, Mar 14, 2024 at 10:04 AM David Joyner  wrote:

> Hi:
>
> I'm trying to show my students a plot of
> a rational function whose graph is basically 1,
> so I plotted
> f(x) = (x^2+0.0001)/(x^2+0.000101)
> However, there is a problem: Note the difference between
> plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10))
> (which dips down near x=0) and
> plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10), ymin = -0.1, ymax = 1.5)
> (which basically looks like a straight line).
> Same problem for lists:
>
> sage: L = [(x/100, f(x/100)) for x in range(-100, 100)]
> sage: list_plot(L)  # bug?
> sage: list_plot(L, ymin=-0.5, ymax=1.5) # good
>
> This is using 'SageMath version 10.3.rc1, Release Date: 2024-02-29' on an
> ubuntu machine. Can anyone tell what is going on here? I'm happy to
> attached jpgs of the plots I get, if desired.
>
> For comparison, it appears that Sympy plots this correctly.
>
> - David Joyner
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-support/CAEQuuAXPcQ6_g67a7L4bdy1Ko%2BFH1VnHAT25G3LfY6XR1mMaEg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq1DheVMU-33w7uvSFn1HrtWqrNWT4ciH6W3AtvF-J4_jw%40mail.gmail.com.


[sage-support] bug in plot?

2024-03-14 Thread David Joyner
Hi:

I'm trying to show my students a plot of
a rational function whose graph is basically 1,
so I plotted
f(x) = (x^2+0.0001)/(x^2+0.000101)
However, there is a problem: Note the difference between
plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10))
(which dips down near x=0) and
plot((x^2+0.0001)/(x^2+0.000101), (x,-10,10), ymin = -0.1, ymax = 1.5)
(which basically looks like a straight line).
Same problem for lists:

sage: L = [(x/100, f(x/100)) for x in range(-100, 100)]
sage: list_plot(L)  # bug?
sage: list_plot(L, ymin=-0.5, ymax=1.5) # good

This is using 'SageMath version 10.3.rc1, Release Date: 2024-02-29' on an
ubuntu machine. Can anyone tell what is going on here? I'm happy to
attached jpgs of the plots I get, if desired.

For comparison, it appears that Sympy plots this correctly.

- David Joyner

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAEQuuAXPcQ6_g67a7L4bdy1Ko%2BFH1VnHAT25G3LfY6XR1mMaEg%40mail.gmail.com.


[sage-support] Bug in plot?

2009-03-18 Thread adrian

If i try to do
plot(cos(x),(x,-3,3))
in sage 3.4 (through the internet version)
it brakes with the message
TypeError: a float is required

The command worked in sage 3.3

Also, in the notebook

sphere()

produces nothing; but
(sphere()).show()
launches the jmol applet as desired.

I don't know if that is the desired behaviour (It wasn't like that in
sage 3.3)
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] bug in plot? Global constants seen as variables.

2009-02-09 Thread Stan Schymanski

Dear all,

For some reason, the meaning of the global constants pi and e (and
maybe others) becomes unavailable to the plot command in the following
example. Is this a bug?

--
| Sage Version 3.2, Release Date: 2008-11-20 |
| Type notebook() for the GUI, and license() for information.|
--

sage: var('h delta phi doy t')
(h, delta, phi, doy, t)
sage: h = 1/12*pi*(t-12)
sage: delta = -23.45*pi/180*cos(2*pi*(doy+10)/365)
sage: sinbeta = cos(h)*cos(delta)*cos(phi)+sin(delta)*sin(phi)
sage: daylength = 12+24/180*arcsin(tan(phi)*sin(delta)/cos(delta))*180/
pi
sage: plot(pi*x,x,0,1)

sage: plot(exp(x),x,0,1)

sage: doy = 180
sage: phi = (30*pi/180).n()
sage: length = daylength.subs(locals()).n()
sage: t0 = 12-0.5*length
sage: t1 = 12+0.5*length
sage: plot(pi*x,x,0,1)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (546, 0))
[...]
ValueError: free variable: pi

sage: plot(exp(x),x,0,1)
[...]
ValueError: free variable: e


Funnily enough, the following fixes the pi-problem for the time being:

sage: pi=pi.n()

But e=e.n() does not fix the e-problem.

Can anyone help?

Thanks a lot,
Stan
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] bug in plot ('e' becomes undefined)

2008-10-16 Thread Stan Schymanski

Dear all,

For some strange reason plot loses its understanding of the system
variable 'e' if I try to plot an exponential function and do
a .subs(locals()) within the plot command. The meaning of 'e' is not
modified in the name space, but its value becomes unavailable to plot
only. See below for an example. Am I doing something wrong, or is it a
bug?

Cheers
Stan

--
| SAGE Version 3.1.2, Release Date: 2008-09-19   |
| Type notebook() for the GUI, and license() for information.|
--

sage: var('d')
d

sage: plot(exp(x-1),0,1)

sage: d=1
sage: plot(exp(x-d).subs(locals()),0,1)
---
ValueErrorTraceback (most recent call
last)

/Users/sschym/ipython console in module()

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
plot/plot.py in plot(funcs, *args, **kwds)
   3561 do_show = kwds.pop('show',False)
   3562 if hasattr(funcs, 'plot'):
- 3563 G = funcs.plot(*args, **kwds)
   3564 # if we are using the generic plotting method
   3565 else:

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
calculus/calculus.py in plot(self, *args, **kwds)
952 param = A[0]
953 try:
-- 954 f = F._fast_float_(param)
955 except NotImplementedError:
956 return self.function(param)

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
calculus/calculus.py in _fast_float_(self, *vars)
   4738 if vars == ():
   4739 vars = self.arguments()
- 4740 fops = [op._fast_float_(*vars) for op in
self._operands]
   4741 return self._operator(*fops)
   4742

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
calculus/calculus.py in _fast_float_(self, *vars)
   4738 if vars == ():
   4739 vars = self.arguments()
- 4740 fops = [op._fast_float_(*vars) for op in
self._operands]
   4741 return self._operator(*fops)
   4742

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
calculus/calculus.py in _fast_float_(self, *vars)
   5275 return fast_float.fast_float_constant(float(self))
   5276 except TypeError:
- 5277 raise ValueError, free variable: %s % self._name
   5278
   5279 def _recursive_sub(self, kwds):

ValueError: free variable: x
sage: plot(exp(x),0,1)
---
ValueErrorTraceback (most recent call
last)

/Users/sschym/ipython console in module()

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
plot/plot.py in plot(funcs, *args, **kwds)
   3561 do_show = kwds.pop('show',False)
   3562 if hasattr(funcs, 'plot'):
- 3563 G = funcs.plot(*args, **kwds)
   3564 # if we are using the generic plotting method
   3565 else:

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
calculus/calculus.py in plot(self, *args, **kwds)
952 param = A[0]
953 try:
-- 954 f = F._fast_float_(param)
955 except NotImplementedError:
956 return self.function(param)

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
calculus/calculus.py in _fast_float_(self, *vars)
   4738 if vars == ():
   4739 vars = self.arguments()
- 4740 fops = [op._fast_float_(*vars) for op in
self._operands]
   4741 return self._operator(*fops)
   4742

/Users/sschym/Programs/sage/local/lib/python2.5/site-packages/sage/
calculus/calculus.py in _fast_float_(self, *vars)
   5275 return fast_float.fast_float_constant(float(self))
   5276 except TypeError:
- 5277 raise ValueError, free variable: %s % self._name
   5278
   5279 def _recursive_sub(self, kwds):

ValueError: free variable: x
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Bug in plot?

2008-09-26 Thread Jason Bandlow

Hi all,

A student of mine noticed the following and it looks like a bug to me
(at least with the documentation).

From the notebook with 3.1.2 (sage prompts added for readability):

sage: plot?

File:
/home/jason/sage/local/lib/python2.5/site-packages/sage/plot/plot.py
Type:type 'function'
Definition:  plot(funcs, *args, **kwds)
Docstring: 

Use plot by writing 

plot(X, ...)

where X is a SAGE object (or list of SAGE objects) that either is
callable and returns numbers that can be coerced to floats, or has
a plot method that returns a GraphicPrimitive object.

Type plot.options for a dictionary of the default
options for plots.  You can change this to change
the defaults for all future plots.  Use plot.reset()
to reset to the default options.

SNIP

sage: plot.options

Traceback (most recent call last):
  File stdin, line 1, in module
  File /home/jason/.sage/sage_notebook/worksheets/admin/32/code/44.py, line 
6, in module
plot.options
  File 
/home/jason/sage/local/lib/python2.5/site-packages/zope.interface-3.3.0-py2.5-linux-i686.egg/,
 line 1, in module

AttributeError: 'function' object has no attribute 'options'


sage: plot.reset() 

Traceback (most recent call last):
  File stdin, line 1, in module
  File /home/jason/.sage/sage_notebook/worksheets/admin/32/code/46.py, line 
6, in module
plot.reset()
  File 
/home/jason/sage/local/lib/python2.5/site-packages/zope.interface-3.3.0-py2.5-linux-i686.egg/,
 line 1, in module

AttributeError: 'function' object has no attribute 'reset'


Cheers,
Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] bug in plot of 2^x?

2007-12-30 Thread David Joyner

Hi:

sage: P = plot(e^(ln(2)*x),-1,1)

works fine (note: e^(ln(2)*x) = 2^x) but

sage: P = plot(2^x,-1,1)
WARNING: When plotting, failed to evaluate function at 201 points.
Last error message: 'exponent (=1.0) must be an integer.
Coerce your numbers to real or complex numbers first.'
---
type 'exceptions.IndexError'Traceback (most recent call last)
...

returns an error.

Seems like a bug. Should I create a track ticket for this?

- David Joyner

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---