簡體   English   中英

如何在浮動圓柱軸中旋轉刻度標簽?

[英]How to rotate tick labels in floating cylindrical axes?

http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html

查看此鏈接的非常底部。 我對中間的軸感興趣,其中軸對象彎曲成四分之一墊圈的形狀。 如果您檢查源代碼,這個軸對象是由 setup_axes2 制作的:

def setup_axes2(fig, rect):
"""
With custom locator and formatter.
Note that the extreme values are swapped.
"""
tr = PolarAxes.PolarTransform()

pi = np.pi
angle_ticks = [(0, r"$0$"),
           (.25*pi, r"$\frac{1}{4}\pi$"),
           (.5*pi, r"$\frac{1}{2}\pi$")]
grid_locator1 = FixedLocator([v for v, s in angle_ticks])
tick_formatter1 = DictFormatter(dict(angle_ticks))

grid_locator2 = MaxNLocator(2)

grid_helper = floating_axes.GridHelperCurveLinear(
    tr, extremes=(.5*pi, 0, 2, 1),
    grid_locator1=grid_locator1,
    grid_locator2=grid_locator2,
    tick_formatter1=tick_formatter1,
    tick_formatter2=None)

ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)
fig.add_subplot(ax1)

# create a parasite axes whose transData in RA, cz
aux_ax = ax1.get_aux_axes(tr)

aux_ax.patch = ax1.patch  # for aux_ax to have a clip path as in ax
ax1.patch.zorder = 0.9  # but this has a side effect that the patch is
# drawn twice, and possibly over some other
# artists. So, we decrease the zorder a bit to
# prevent this.

return ax1, aux_ax

當我在 theta 軸上標記刻度時,標簽總是顛倒的。 我不知道如何翻轉它們。 我也不知道如何顛倒軸標簽。 有誰知道這些令人困惑的浮動軸?

提示位於您鏈接的示例中的setup_axes3() FloatingSubplot中的各個軸被稱為ax.axis[side] ,其中side["top","bottom","left","right"] 從那里你得到通常的。

ax = ax2.axis["bottom"]
ax.major_ticklabels.set_rotation(180)
ax.set_label("foo")
ax.label.set_rotation(180)
ax.LABELPAD += 10

只需執行dir(ax)即可查看您可以訪問的內容。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM