Opened 5 years ago
Closed 3 years ago
#16857 closed enhancement (fixed)
Add example(s) for ticks in plot doc
Reported by:  kcrisman  Owned by:  ljern 

Priority:  minor  Milestone:  sage7.5 
Component:  graphics  Keywords:  beginner 
Cc:  Merged in:  
Authors:  Lennart Jern  Reviewers:  Paul Masson 
Report Upstream:  N/A  Work issues:  
Branch:  8d10514 (Commits)  Commit:  8d10514e1b4a7038077a0a6b01a99e2ec40ffd16 
Dependencies:  Stopgaps: 
Description
This ask.sagemath question suggests we need more documentation on how to change ticks for only one axis. One suggested example is
xx = np.logspace(1,100,1000) yy = np.linspace(180,180,1000) list_plot(xx,yy,scale=semilogx,ticks=[None, 30])
though neither of us has tested this yet.
Attachments (1)
Change History (21)
comment:1 Changed 5 years ago by
 Status changed from new to needs_review
comment:2 Changed 5 years ago by
Certainly this would be the correct syntax, now that I see it. Probably we should add some (nonsemilog, non list plot) examples in a few other places where there are already ticks examples. Nice!
comment:4 Changed 3 years ago by
 Branch set to u/ljern/doc_ticks_in_plot
comment:5 Changed 3 years ago by
 Commit set to 9c7d90c9e9627aabe34e0d76e4e7cc7df5844eb7
 Owner changed from (none) to ljern
First attempt at contributing to sage...
New commits:
9c7d90c  Added more documentation about ticks in plots

comment:6 Changed 3 years ago by
 Commit changed from 9c7d90c9e9627aabe34e0d76e4e7cc7df5844eb7 to d2a7a27a62be75696b5ad6a3793bf63819aac99f
Branch pushed to git repo; I updated commit sha1. New commits:
d2a7a27  More documentation for ticks in plots

comment:7 followup: ↓ 8 Changed 3 years ago by
 Status changed from needs_work to needs_review
I added an example to plot
where only one axis is changed.
Since list_plot
has no other examples with keywords, I decided to just add a reference to show
there rather than adding the same example in two places.
All the other plot functions also makes references to show or plot for full details.
I realized now that I branched from develop
, is this OK? Should I branch from master
instead?
comment:8 in reply to: ↑ 7 Changed 3 years ago by
Replying to ljern:
I added an example to
plot
where only one axis is changed. Sincelist_plot
has no other examples with keywords, I decided to just add a reference toshow
there rather than adding the same example in two places. All the other plot functions also makes references to show or plot for full details.
I would redirect to plot
instead of show
since show
does more than plot
. plot
returns a plot object, whereas show
returns None
and displays a plot. In an analogy, plot
is like a function that returns a string, whereas show
is like print
.
I realized now that I branched from
develop
, is this OK? Should I branch frommaster
instead?
You should always try to base things off develop
as it is far less likely to have any merge conflicts or behavior changes.
comment:9 Changed 3 years ago by
 Commit changed from d2a7a27a62be75696b5ad6a3793bf63819aac99f to 7c0d1508bcc97c42d28bdb9679cbe5478fcbc9c6
Branch pushed to git repo; I updated commit sha1. New commits:
7c0d150  Changed reference from show to plot

comment:10 Changed 3 years ago by
We've been putting white space between the arguments of Sage commands but not within the arguments. The command
plot(x^2,(x,300,500),ticks=[100,50000])
reads better as
plot(x^2, (x,300,500), ticks=[100,50000])
Please make that change in the immediate section on which you're working. Thanks!
comment:11 Changed 3 years ago by
Please also put your full real name in the "Authors" field.
comment:12 Changed 3 years ago by
 Commit changed from 7c0d1508bcc97c42d28bdb9679cbe5478fcbc9c6 to 213595493b1ebc555e15cde2977935f89ad13801
Branch pushed to git repo; I updated commit sha1. New commits:
2135954  Added myself to authors, improved readability of examples

comment:13 Changed 3 years ago by
Lennart, when I asked you to add yourself to authors I meant on the Trac ticket, not in the documentation.
One more change I would like to see it four instances of 1,27
changed to 1, 27
. Thanks!
comment:14 Changed 3 years ago by
 Milestone set to sage7.5
 Reviewers set to Paul Masson
comment:15 Changed 3 years ago by
Oh I see, that makes sense! Thank you for the guidance :) I guess I should also merge the develop branch into this to make it up to date, right?
comment:16 Changed 3 years ago by
 Commit changed from 213595493b1ebc555e15cde2977935f89ad13801 to 4d3ceb478f0125a14f36d04d9793906753150da8
comment:17 Changed 3 years ago by
You aren't required to merge the current develop branch if it doesn't affect your code. Some people do that regularly to avoid possible merge conflicts and to decrease the time it takes to rebuild after changes. I personally don't because it complicates the history of a branch in the Git repository, and rebuild time can be decreased significantly in any case by installing ccache
.
You also don't need to include a patch with all changes. The commits to Git are cumulative, and you can see the total result by clicking on the branch at the top of this ticket.
The documentation builds and looks good. One more minor change: add a space so x^2,(x,480,500)
is x^2, (x,480,500)
to match the edit in the Sphinx plot. After that its good to go and I'll give it positive review.
comment:18 Changed 3 years ago by
 Commit changed from 4d3ceb478f0125a14f36d04d9793906753150da8 to 8d10514e1b4a7038077a0a6b01a99e2ec40ffd16
Branch pushed to git repo; I updated commit sha1. New commits:
8d10514  More space for readability

comment:20 Changed 3 years ago by
 Branch changed from u/ljern/doc_ticks_in_plot to 8d10514e1b4a7038077a0a6b01a99e2ec40ffd16
 Resolution set to fixed
 Status changed from positive_review to closed
I was unable to get the suggested example to work, as i get this error when trying it:
Also i needed to add single quotes around semilogx, so i ended up with this:
And it produces a plot successfully, but i have no idea if that plot is correct, now with these changes?