繁体   English   中英

顶部和右侧脊柱上的对数刻度

[英]Logarithmic Ticks on Top and Right Spine

我正在尝试在盒子的所有侧面使用对数刻度进行可视化。

import numpy as np
import matplotlib.pyplot as plt

x  = np.logspace(2, 5, 5)
y  = 0.5*x**(-1/2)
y2 = 0.01*x**(-1/2)
y3 = 0.05*x**(-1/3)

fig, ax = plt.subplots()

ax.plot(x, y, 'o-', label="One")
ax.plot(x, y2, '*-', label="Two")
ax.plot(x, y3, '--', label="Three")

ax.set(
    
    xlabel='Input',
    xlim=(1e2, 1e5),
    xscale='log',
    
    ylabel='Output',
    ylim=(1e-5, 1e-1), 
    yscale='log',   
)

ax.tick_params(top=True, right=True) # <-- This didn't work how I expected.

ax.legend(loc='lower left');

日志日志图

我想要顶部和右侧脊椎上的相关次要刻度线。

关于如何实现这一点的任何建议?

使用Axes.tick_paramswhich参数:

ax.tick_params(which='both', top=True, right=True)

Output:

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM