How to rotate a simple matplotlib Axes

matplotlib, python

Solution

Are you asking how to rotate the entire axes (and not just the text)?

If so, yes, it's possible, but you have to know the extents of the plot beforehand.

You'll have to use `axisartist`, which allows more complex relationships like this, but is a bit more complex and not meant for interactive visualization. If you try to zoom, etc, you'll run into problems.

import matplotlib.pyplot as plt
from matplotlib.transforms import Affine2D
import mpl_toolkits.axisartist.floating_axes as floating_axes

fig = plt.figure()

plot_extents = 0, 10, 0, 10
transform = Affine2D().rotate_deg(45)
helper = floating_axes.GridHelperCurveLinear(transform, plot_extents)
ax = floating_axes.FloatingSubplot(fig, 111, grid_helper=helper)

fig.add_subplot(ax)
plt.show()

Problem

is it possible to rotate matplotlib.axes.Axes as it is for matplotlib.text.Text ``` # text and Axes instance t = figure.text(0.5,0.5,"some text") a = figure.add_axes([0.1,0.1,0.8,0.8]) # rotation t.set_rotation(angle) a.set_rotation()??? ``` a simple set_rotation on a text instance will rotate the text by the angle value about its coordinates axes. Is there any way to do to same for the axes instance ?

Original source