【问题标题】:How do I change x and y axis limits in seaborn如何更改 seaborn 中的 x 和 y 轴限制
【发布时间】:2021-05-17 15:09:35
【问题描述】:

以下是我的 x 和 y 坐标值

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()

x = np.random.randint(1,10,10)
y = np.random.randint(-100,10,10)
plt.scatter(x,y)

例如,我如何更改 x 和 y 坐标的最大值和最小值

如果我想将 X 轴左更改为 -5,右更改为 10 同样 Y 轴底部到 -100 和顶部 -20

结果图

【问题讨论】:

标签: python seaborn axis


【解决方案1】:

请在 plt.scattar 之前添加这个

plt.xlim([-5, 10])
plt.ylim([-100, -20])

此致,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-14
    • 1970-01-01
    • 1970-01-01
    • 2012-04-22
    • 2020-10-21
    相关资源
    最近更新 更多