So, it seems one cannot do the following (it raises an error, since axes
does not have a set_linewidth
method):
axes_style = {'linewidth':5} axes_rect = [0.1, 0.1, 0.9, 0.9] axes(axes_rect, **axes_style)
and has to use the following old trick instead:
rcParams['axes.linewidth'] = 5 # set the value globally ... # some code rcdefaults() # restore [global] defaults
Is there an easy / clean way (may be one can set x
- and y
- axes parameters individually, etc)?
If no, why?
Axis spines are the lines confining the plot area. Depending on the situation, we may want to remove some (or all) of them, change their color, make them less visible, regulate their width/style, or change their position. In this article, we'll explore some handy approaches for dealing with axis spines.
Another way to change the visual appearance of plots is to set the rcParams in a so-called style sheet and import that style sheet with matplotlib. style. use . In this way you can switch easily between different styles by simply changing the imported style sheet.
Matplotlib allows you to adjust the line width of a graph plot using the linewidth attribute. If you want to make the line width of a graph plot thinner, then you can make linewidth less than 1, such as 0.5 or 0.25.
spines
.import matplotlib.pyplot as plt fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 4)) ax1.set_title('Normal spine and ticks') ax2.set_title('Adjusted spine and ticks') # change each spine separately: # ax.spines['right'].set_linewidth(0.5) # change all spines for axis in ['top','bottom','left','right']: ax2.spines[axis].set_linewidth(4) # increase tick width ax2.tick_params(width=4) plt.show()
plt.setp(ax.spines.values(), linewidth=5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With