Ask Your Question

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

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 close merge delete

## Comments

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

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

## 1 Answer

Sort by ยป oldest newest most voted

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.

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?

( 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.

( 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

## Stats

Asked: 2022-05-24 17:19:11 +0100

Seen: 417 times

Last updated: May 25 '22