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: sage-7.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)

ticks.patch (5.5 KB) - added by ljern 3 years ago.
Patch with all changes

Download all attachments as: .zip

Change History (21)

comment:1 Changed 5 years ago by paulgraham5

  • Status changed from new to needs_review

I was unable to get the suggested example to work, as i get this error when trying it:

TypeError: The second argument 'plotjoined' should be boolean (True or False).  
If you meant to plot two lists 'x' and 'y' against each other, 
use 'list_plot(zip(x,y))'.

Also i needed to add single quotes around semilogx, so i ended up with this:

list_plot(zip(xx,yy),scale='semilogx',ticks=[None, Integer(30)])

And it produces a plot successfully, but i have no idea if that plot is correct, now with these changes?

comment:2 Changed 5 years ago by kcrisman

Certainly this would be the correct syntax, now that I see it. Probably we should add some (non-semilog, non list plot) examples in a few other places where there are already ticks examples. Nice!

comment:3 Changed 5 years ago by vbraun

  • Status changed from needs_review to needs_work

no branch to review

comment:4 Changed 3 years ago by ljern

  • Branch set to u/ljern/doc_ticks_in_plot

comment:5 Changed 3 years ago by ljern

  • Commit set to 9c7d90c9e9627aabe34e0d76e4e7cc7df5844eb7
  • Owner changed from (none) to ljern

First attempt at contributing to sage...


New commits:

9c7d90cAdded more documentation about ticks in plots

comment:6 Changed 3 years ago by git

  • Commit changed from 9c7d90c9e9627aabe34e0d76e4e7cc7df5844eb7 to d2a7a27a62be75696b5ad6a3793bf63819aac99f

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

d2a7a27More documentation for ticks in plots

comment:7 follow-up: Changed 3 years ago by ljern

  • 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 tscrim

Replying to ljern:

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 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 from master 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 git

  • Commit changed from d2a7a27a62be75696b5ad6a3793bf63819aac99f to 7c0d1508bcc97c42d28bdb9679cbe5478fcbc9c6

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

7c0d150Changed reference from show to plot

comment:10 Changed 3 years ago by paulmasson

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 paulmasson

Please also put your full real name in the "Authors" field.

comment:12 Changed 3 years ago by git

  • Commit changed from 7c0d1508bcc97c42d28bdb9679cbe5478fcbc9c6 to 213595493b1ebc555e15cde2977935f89ad13801

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

2135954Added myself to authors, improved readability of examples

comment:13 Changed 3 years ago by paulmasson

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 paulmasson

  • Milestone set to sage-7.5
  • Reviewers set to Paul Masson

comment:15 Changed 3 years ago by ljern

  • Authors set to Lennart Jern

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?

Last edited 3 years ago by ljern (previous) (diff)

comment:16 Changed 3 years ago by git

  • Commit changed from 213595493b1ebc555e15cde2977935f89ad13801 to 4d3ceb478f0125a14f36d04d9793906753150da8

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

61f558bAdded space between some arguments, removed from authors
4d3ceb4Merge branch 'develop' into t/16857/doc_ticks_in_plot

Changed 3 years ago by ljern

Patch with all changes

comment:17 Changed 3 years ago by paulmasson

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 git

  • Commit changed from 4d3ceb478f0125a14f36d04d9793906753150da8 to 8d10514e1b4a7038077a0a6b01a99e2ec40ffd16

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

8d10514More space for readability

comment:19 Changed 3 years ago by paulmasson

  • Status changed from needs_review to positive_review

Thanks!

comment:20 Changed 3 years ago by vbraun

  • Branch changed from u/ljern/doc_ticks_in_plot to 8d10514e1b4a7038077a0a6b01a99e2ec40ffd16
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.