Anonymous
Как выровнять повернутую вверх ylabel с правой стороны графика с помощью matplotlib
Сообщение
Anonymous » 09 янв 2025, 14:11
Как в matplotlib я могу добиться выравнивания метки y по верхней части графика, когда метка поворачивается, перемещается вправо и вверх?
Код: Выделить всё
import matplotlib.pyplot as plt
import numpy as np
#create plot
fig, ax = plt.subplots()
ax.plot(np.sin(np.linspace(-np.pi, np.pi, 1001)))
ax.tick_params(
which="both",
direction="out",
left=False,
right=True,
labelleft=False,
labelright=True,
)
ax.set_ylabel("y-label", loc="top", rotation=-90, labelpad=10)
ax.yaxis.set_label_position("right")
Подробнее здесь:
https://stackoverflow.com/questions/793 ... matplotlib
1736421098
Anonymous
Как в matplotlib я могу добиться выравнивания метки y по верхней части графика, когда метка поворачивается, перемещается вправо и вверх? [code]import matplotlib.pyplot as plt import numpy as np #create plot fig, ax = plt.subplots() ax.plot(np.sin(np.linspace(-np.pi, np.pi, 1001))) ax.tick_params( which="both", direction="out", left=False, right=True, labelleft=False, labelright=True, ) ax.set_ylabel("y-label", loc="top", rotation=-90, labelpad=10) ax.yaxis.set_label_position("right") [/code] [img]https://i.sstatic.net/Hv9rgVOy.png[/img] Подробнее здесь: [url]https://stackoverflow.com/questions/79342338/how-to-align-top-rotated-ylabel-on-the-righthand-side-on-a-plot-with-matplotlib[/url]