#4529: Implement plots with logarithmic scale
-----------------------------------------+----------------------------------
Reporter: ronanpaixao | Owner: ronanpaixao
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-5.1
Component: graphics | Resolution:
Keywords: plot log scale | Work issues: convenience functions
Report Upstream: N/A | Reviewers: Karl-Dieter Crisman
Authors: Punarbasu Purkayastha | Merged in:
Dependencies: #12974 | Stopgaps:
-----------------------------------------+----------------------------------
Comment (by kcrisman):
> Actually, there is zero change to be done to the code in `plot` or
`list_plot`, except to add some examples. The only change that the
additional patch will do is make very thin (one-liners) wrappers which
defines the `plot_*` and `list_plot_*` wrappers and pass the correct scale
option to `plot` and `list_plot`. The current consensus from the poll
seems to favor this syntax. In view of this, the patch
[attachment:trac_4529-add_docs_eg_to_some_user_facing_functions.patch]
requires only a renaming of the functions, and some extra examples.
Oh, I didn't realize that that patch actually already implemented that - I
hadn't had time to look at the patches until you had already said which
patches to apply! Yes, I should be able to rebase/rename that well for
our purposes, just adding a few more examples which occur fairly
frequently.
> We can add exactly similar examples to `plot()` and `list_plot()`.
Currently, since the function is `Graphics.show()`, I decided to write it
as `show(scale=...)` instead of `plot(scale=...)` since the former is more
pertinent.
Of course.
> > * As to the optional patch, I will think about this some more
tomorrow. I do note that things still "work". For the example you
removed `G`, the example you removed did in fact work, for instance.
>
> Yes I am aware that the examples I provided work. But most of the
examples in the docs of those functions (arc, disk, contour_plot, etc)
''do not'' work out of the box, and we get the "too few ticks" error.
But they 'work', just not with the log scale, right?
> > I'm not sure whether having minor ticks should count as "having two
ticks", especially in the relatively obscure-looking log plot situation.
I'm not even sure why
> > {{{
> > sage: G.show(scale=('loglog', 2))
> > }}}
> > works, since there is only one tick on the left!
>
> Yes. That's why I said that the tick checking function is not robust and
I also don't know how to make it robust.
Haha. Well, I spent about a half-hour looking in depth at the code for
`matplotlib.ticker.LogLocator` and have decided it is nearly impossible.
There will very often, especially for `base=2` and friends, be ticks in
the locator which are outside of the viewing range.
So there are ways to get some of this information... yuck. I may have
something for this later today. I've been looking at it for over an hour
and, at least for plots with only positive data, I think I have something.
For ones with negative data it would be much more ugly and maybe not worth
it.
By the way, I get
{{{
sage: sage: disk((0,0), 1, (0, 3*pi/2)).show(scale='semilogx',base=2)
/Users/.../sage-5.1.beta0/local/lib/python2.7/site-
packages/matplotlib/axes.py:1114: UserWarning: aspect is not supported for
Axes with xscale=log, yscale=linear
% (xscale, yscale))
}}}
when I try something that has an aspect ratio defined (disk, etc.)
> The minor ticks are generated by passing in multiples of 1/base to the
subs parameter of LogLocator. So, for base 10, you will have ticks at say,
`0.1*10^-1, 0.2*10^-1, ..., 0.9*10^-1, 10^-1`. This is a typical way how
log plots are drawn in all programs (`pyplot.loglog()`, matlab,
mathematica, etc). For `base=2` you can have only one tick `1/2*2^i` but
this is a major tick at `2^(i-1)`. So, you will always see only one major
tick and no minor ticks.
I understood that, but didn't think through the implications for `base=2`.
By the way, maybe changing
{{{
srange(base_inv, 1+base_inv, base_inv)
}}}
to
{{{
srange(2*base_inv, 1, base_inv)
}}}
would be useful, so that minor and major ticks don't overlap... probably
doesn't matter, but could be ok.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4529#comment:47>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.