如何在JupyterLab中画一条特定长度的线?

问题描述 投票:0回答:1

我希望能够在JupyterLab中画一条线,线的长度由我决定。

def drawLine(inches):
    pass

40年来,我在无数其他语言和平台上做过这样的工作 但从来没有像在JupyterLab中那样困难。Matplotlib将布局掌握在自己手中,而不是给我提供完善的布局控制,导致我得到的实际上是随机的线长;所以我为了在matplotlib中做到这一点,已经杀了三天。当我试着在Reddit上寻求帮助时,我受到了精神上的拒绝者和业余爱好者的骚扰和侮辱。我想使用除了Matplotlib之外的任何图形模块,但我不知道从哪里开始。JupyterLab的文档并没有让它变得简单。

jupyter jupyter-lab
1个回答
0
投票
import matplotlib.pyplot as plt

def drawline(inches):
    x1, y1 = [0, inches], [0, 0] # horizontal line
    x2, y2 = [0, 0], [0, inches] # vertical line

    plt.plot(x1, y1, x2, y2, marker='o')
    plt.show()

drawline(8)
© www.soinside.com 2019 - 2024. All rights reserved.