4 examples of 'plt rotate x labels' in Python

Every line of 'plt rotate x labels' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
17def rotateTickLabels(ax, rotation, which, rotation_mode="anchor", ha="right"):
18 """ Rotates the ticklabels of a matplotlib Axes
19
20 Parameters
21 ----------
22 ax : matplotlib Axes
23 The Axes object that will be modified.
24 rotation : float
25 The amount of rotation, in degrees, to be applied to the labels.
26 which : string
27 The axis whose ticklabels will be rotated. Valid values are 'x',
28 'y', or 'both'.
29 rotation_mode : string, optional
30 The rotation point for the ticklabels. Highly recommended to use
31 the default value ('anchor').
32 ha : string
33 The horizontal alignment of the ticks. Again, recommended to use
34 the default ('right').
35
36 Returns
37 -------
38 None
39
40 """
41
42 if which == "both":
43 rotateTickLabels(ax, rotation, "x", rotation_mode=rotation_mode, ha=ha)
44 rotateTickLabels(ax, rotation, "y", rotation_mode=rotation_mode, ha=ha)
45 else:
46 if which == "x":
47 axis = ax.xaxis
48
49 elif which == "y":
50 axis = ax.yaxis
51
52 for t in axis.get_ticklabels():
53 t.set_horizontalalignment(ha)
54 t.set_rotation(rotation)
55 t.set_rotation_mode(rotation_mode)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

372def set_axis_labels ( self , x ) :
373 pass
270def set_xticklabels(xticklabels,
271 rotation = 'vertical',
272 fontsize = 16,
273 **kargs):
274 ax = plt.gca()
275 ax.set_xticklabels(xticklabels, rotation = rotation,
276 fontsize = fontsize, **kargs)
246def auto_axis_label(ax, y_scale, z_non_zero=True, log_x=False):
247
248 if tex_on:
249 if z_non_zero:
250 ax.set_ylabel("$\\mathrm{f_{\\lambda}}\\ \\mathrm{/\\ 10^{"
251 + str(y_scale)
252 + "}\\ erg\\ s^{-1}\\ cm^{-2}\\ \\AA^{-1}}$")
253
254 else:
255 ax.set_ylabel("$\\mathrm{f_{\\lambda}}\\ \\mathrm{/\\ 10^{"
256 + str(y_scale)
257 + "}\\ erg\\ s^{-1}\\ \\AA^{-1}}$")
258
259 if log_x:
260 ax.set_xlabel("$\\mathrm{log_{10}}\\big(\\lambda / \\mathrm{\\AA}"
261 + "\\big)$")
262
263 else:
264 ax.set_xlabel("$\\lambda / \\mathrm{\\AA}$")
265
266 else:
267 if z_non_zero:
268 ax.set_ylabel("f_lambda / 10^" + str(y_scale)
269 + " erg s^-1 cm^-2 A^-1")
270
271 else:
272 ax.set_ylabel("f_lambda / 10^" + str(y_scale)
273 + " erg s^-1 A^-1")
274
275 if log_x:
276 ax.set_xlabel("log_10(lambda / A)")
277
278 else:
279 ax.set_xlabel("lambda / A")

Related snippets