Question

In the 3D figures in Mayavi, I want to change the font type and size of the axis label and legend. I know it's possible to do it in UI, but How to do it by coding? Is it possible to use different font type in legend and axis label? Thanks!

Was it helpful?

Solution

Given an axes object, you can just set the values of the label_text_property like so:

axes.label_text_property.font_family = 'courier'
axes.label_text_property.font_size = 10

Similarly, the "legend" font (I assume you mean the axes titles) may be set by:

axes.title_text_property.font_family = 'times'
axes.title_text_property.font_size = 14

It looks like the typefaces available might be a bit limited, though.

In the future you should really look at the "record" feature, to glean how to do things with code that you're doing through the GUI. That's how I just looked up these properties.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top