First time here? Check out the FAQ!

Ask Your Question
1

tick formatter pi cause the plot of squared sine function to have long tick label

asked 2 years ago

Martine gravatar image

updated 2 years ago

sage: plot(sin(x)^2)

This is normal. but if you use the below code:

sage: plot(sin(x)^2, tick_formatter=pi)

You will get very long y axis tick labels.

The version of sagemath is 9.6-2, from arch linux package repository.

edit: tick_formatter=[pi, None] will give the normal result, but according to the documentation of Graphics objects, about tick_formatter:

If the value of this keyword is a single item, then this will give the formatting for the horizontal axis only (except for the "latex" option).

So my code should work, but it did not work.

Preview: (hide)

Comments

the version of sagemath is 9.6-2, from archlinux package repository

Martine gravatar imageMartine ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 2 years ago

eric_g gravatar image

Instead of tick_formatter=pi, you can use tick_formatter=(pi, None); this specifies that the pi tick formatter is only for the x-axis, the y-axis keeping the default formatter (this is what you want, I guess). This produces the correct output, without any long y-axis tick label.

Preview: (hide)
link

Comments

Thank you for quick replying! Although this solution works, according to the https://doc.sagemath.org/html/en/reference/plotting/sage/plot/graphics.html?highlight=tick_formatter#sage.plot.graphics.Graphics.show (documentation) of tick_formatter, If the value of this keyword is a single item, then this will give the formatting for the horizontal axis only. So I think it may be a bug?

Martine gravatar imageMartine ( 2 years ago )

You are right: it's a bug. It seems to be related to https://trac.sagemath.org/ticket/15776.

eric_g gravatar imageeric_g ( 2 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2 years ago

Seen: 877 times

Last updated: May 25 '22