如何将坐标线一路带到轴线?

发布于 2025-02-11 16:24:24 字数 777 浏览 0 评论 0 原文

如何将坐标线一路带到轴上?这是我的代码:

X, Y = df['xdata'], df['ydata']

xs=[4]
ys=[6.7]
colors=['b']

fig, ax = plt.subplots(figsize=(8, 8))
ax.scatter(xs, ys, c=colors)

plt.plot(X,Y, marker=' ', markersize=3, linewidth=1, color='black')
plt.xlabel('Anoxic tank volume (m³)', fontsize=14)
plt.xticks(fontsize=14)
plt.ylabel('Effluent TN (mg/L)', fontsize=14)
plt.yticks(fontsize=14)

for x, y, c in zip(xs, ys, colors):
    ax.plot([x, x], [0, y], c=c, ls='-.', lw=2.0, alpha=0.5)
    ax.plot([0, x], [y, y], c=c, ls='-.', lw=2.0, alpha=0.5)
    
plt.show()

给出:

”在此处输入图像说明”

How can I bring the coordinate lines all the way to the axis? Here is my code:

X, Y = df['xdata'], df['ydata']

xs=[4]
ys=[6.7]
colors=['b']

fig, ax = plt.subplots(figsize=(8, 8))
ax.scatter(xs, ys, c=colors)

plt.plot(X,Y, marker=' ', markersize=3, linewidth=1, color='black')
plt.xlabel('Anoxic tank volume (m³)', fontsize=14)
plt.xticks(fontsize=14)
plt.ylabel('Effluent TN (mg/L)', fontsize=14)
plt.yticks(fontsize=14)

for x, y, c in zip(xs, ys, colors):
    ax.plot([x, x], [0, y], c=c, ls='-.', lw=2.0, alpha=0.5)
    ax.plot([0, x], [y, y], c=c, ls='-.', lw=2.0, alpha=0.5)
    
plt.show()

Which gives:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟沫凡尘 2025-02-18 16:24:24

尝试使用 > and ylim

plt.xlim([0, X.max()])
plt.ylim([0, Y.max()])

Try using matplotlib.pyplot.xlim and matplotlib.pyplot.ylim:

plt.xlim([0, X.max()])
plt.ylim([0, Y.max()])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文