Ask Your Question
1

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

asked 2022-05-24 17:26:25 +0100

Martine gravatar image

updated 2022-05-25 04:56:31 +0100

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.

edit retag flag offensive close merge delete

Comments

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

Martine gravatar imageMartine ( 2022-05-24 17:27:03 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-05-24 18:56:32 +0100

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.

edit flag offensive delete link more

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 ( 2022-05-25 04:47:25 +0100 )edit

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

eric_g gravatar imageeric_g ( 2022-05-26 12:03:14 +0100 )edit

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: 2022-05-24 17:19:11 +0100

Seen: 711 times

Last updated: May 25 '22