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

Setting custom formatter in so.Nominal().label() seems to do nothing #3713

Open
rbergm opened this issue Jun 20, 2024 · 1 comment
Open

Setting custom formatter in so.Nominal().label() seems to do nothing #3713

rbergm opened this issue Jun 20, 2024 · 1 comment

Comments

@rbergm
Copy link

rbergm commented Jun 20, 2024

When using the so.Nominal() scale of the objects interface, calling label() with a custom formatter seems to have no effect. Could also be that I am using the function in an incorrect way, since the API and documentation on the nominal scale are still being worked on.

Demo:

import matplotlib as mpl
import numpy as np
import pandas as pd
import seaborn.objects as so

xs = range(10)
ys = np.random.random(10)
df = pd.DataFrame(dict(x=xs, y=ys))
formatter = mpl.ticker.FuncFormatter(lambda x, pos: str(x) if x % 3 == 0 else "")

(so.Plot(df, x="x", y="y")
 .add(so.Dots())
 .scale(x=so.Nominal().label(formatter))
)

demo

The x-axis ticks are correctly transformed to a nominal scale. However, I would expect to only see tick labels that divide by 3 based on the formatter.

Tested on Seaborn v0.13.2 and Matplotlib v3.9.0

@rbergm rbergm changed the title Setting custom formatter in so.Nominal().label seems to do nothing Setting custom formatter in so.Nominal().label() seems to do nothing Jun 20, 2024
@heimyoo
Copy link

heimyoo commented Oct 18, 2024

Can I take it??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants