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

Automatically changing ticks label font size #19

Closed
ijpulidos opened this issue Apr 19, 2020 · 2 comments
Closed

Automatically changing ticks label font size #19

ijpulidos opened this issue Apr 19, 2020 · 2 comments

Comments

@ijpulidos
Copy link

For changing ticks label font size pylustrator is currently doing it manually tick by tick. For example if I want to change the tick font size to 14 and there are 8 ticks, I get something like the following:

plt.figure(1).axes[0].get_xaxis().get_major_ticks()[0].label1.set_fontsize(14)
plt.figure(1).axes[0].get_xaxis().get_major_ticks()[1].label1.set_fontsize(14)
...
plt.figure(1).axes[0].get_xaxis().get_major_ticks()[7].label1.set_fontsize(14)

I think this could be done programatically by looping through plt.figure(1).axes[0].get_xaxis().get_major_ticks() directly, then you can use the same pylustrator autogenerated code in many figures without having to manually edit the number of ticks by adding or removing lines. For example something like:

# Change major tick font size dynamically
for major_tick in plt.figure(1).axes[0].get_xaxis().get_major_ticks():
    major_tick.label1.set_fontsize(14)

should do it.

@mmagnuski
Copy link

mmagnuski commented Aug 10, 2020

That would be great - would improve pylustrator's output readibility a lot. When changing fontsize of both x and y ticklabels I get a wall of 18 lines of code, which could be 3 -4.

@rgerum rgerum closed this as completed in 923933b Aug 17, 2020
@rgerum
Copy link
Owner

rgerum commented Aug 17, 2020

Ok, I fixed this my setting the font properties directly in set_xticklabels. This makes it easier as the for loop in the generated code would make it more difficult when parsing in the automatically generated code (it needs to be parsed by pylustrator to know which changes where from pylustrator and which from the original code).

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

3 participants