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

Apply style to tick labels in customize labels throws an error #3189

Open
butlerpd opened this issue Jan 18, 2025 · 1 comment
Open

Apply style to tick labels in customize labels throws an error #3189

butlerpd opened this issue Jan 18, 2025 · 1 comment
Assignees

Comments

@butlerpd
Copy link
Member

Describe the bug
Using the new option in the plot context menu Customize Labels there is a checkbox for each axis to apply the styles chosen for the axis labels to the tick labels as well Apply Style to Tick Labels. When doing so the following error is thrown in the console

18:15:21 - ERROR: Traceback (most recent call last): File "sas\qtgui\Plotting\Plotter.py", line 914, in onCusotmizeLabel File "matplotlib\axes\_base.py", line 74, in wrapper TypeError: Axis.set_ticklabels() takes 2 positional arguments but 3 were given

To Reproduce
Steps to reproduce the behavior:

  1. Create a plot (either load a data set and plot or plot a theory curve)
  2. Right click on plot and choose Customize Labels
  3. You can make changes to the fonts or font size etc but that is not necessary to get the error.
  4. check the checkbox labelled Apply style to X tick labels or to the corresponding checkbox for the Y tick labels
  5. Press OK
  6. See error

Expected behavior
the tick labels change to match the style of the axis labels and no error is thrown.

SasView version (please complete the following information):

  • Version: 6.0.0. Version 5.0.6 does not have the Customize Labels option so this is an error introduced to 6.0.0. However, it is not clear WHY this was not in 5.0.6 as the code seems to have been added in July 2022, a year prior to the release of 6.0.0?

Operating system (please complete the following information):

  • OS: found on Windows 10

Additional context
The error is caused by the following:

        if apply_x:
            # self.ax.tick_params(axis='x', labelsize=fx.size, labelcolor=fx.color)
            from matplotlib.pyplot import gca
            a = gca()
            a.set_xticklabels(a.get_xticks(), fx)
        if apply_y:
            # self.ay.tick_params(axis='y', labelsize=fy.size, labelcolor=fy.color)
            from matplotlib.pyplot import gca
            a = gca()
            a.set_yticklabels(a.get_yticks(), fy)

specifically the lines a.set_xticklabels(a.get_xticks(), fx)

The problem from what I've read so far suggests that set_xticklabels takes a list of the tick mark strings (here provided by a.get_yticks() I think) and a series of kwargs? so it should be fontsize=fx or some such maybe?

@jamescrake-merani
Copy link
Contributor

I can reproduce the problem. I will investigate today.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants