Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update labels on trig graphs #533

Open
siwelwerd opened this issue Dec 20, 2024 · 3 comments
Open

Update labels on trig graphs #533

siwelwerd opened this issue Dec 20, 2024 · 3 comments
Labels
enhancement New feature or request precalculus

Comments

@siwelwerd
Copy link
Contributor

siwelwerd commented Dec 20, 2024

In Section PF1 and maybe elsewhere, there are a bunch of trig graphs with tick marks labeled things like $\frac{1}{2} \pi$. But in looking at one of the images in Calculus CO-4 I figured out how to get these to typeset as $\frac{\pi}{2}$. We should copy that idea over to make the other graphs look nicer.

@siwelwerd siwelwerd added enhancement New feature or request precalculus labels Dec 20, 2024
@siwelwerd
Copy link
Contributor Author

Hmm, this is more involved than I thought it would be.

@siwelwerd
Copy link
Contributor Author

Key insight from the Sage documentation: "Custom tick labels can be provided by providing the keyword tick_formatter with the list of labels, and simultaneously providing the keyword ticks with the positions of the labels."

Wired this up into a quick proof of concept

Old image:

image

New image:
image

Code:

f(x) = sin(x)
p=Graphics()
xmin=-2*pi
xmax=4*pi
delta=pi/4
custom_ticks=[]
custom_tick_labels=[]
for x in [xmin+delta*i for i in [0.. int((xmax-xmin)/delta)]]:
    if denominator(x) != 1:
        custom_tick_labels.append(f"$\\dfrac{{{latex(numerator(x))}}}{{{denominator(x)}}}$")
        custom_ticks.append(x)
    else:
        custom_ticks.append(x)
        custom_tick_labels.append(f"${latex(x)}$")
        
p+=plot(f, (x, xmin, xmax), color='blue', thickness=3, detect_poles=True,ticks=[custom_ticks,0.5], tick_formatter=[custom_tick_labels,"latex"])
show(p)

Probably the "right" thing to do is factor this into a function in our common.sage

@siwelwerd
Copy link
Contributor Author

Probably the "right" thing to do is factor this into a function in our common.sage

Ah, but that's probably blocked by #361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request precalculus
Projects
None yet
Development

No branches or pull requests

1 participant