gpt4 book ai didi

matplotlib - 设置 mpld3 图的高度和宽度

转载 作者:行者123 更新时间:2023-12-02 15:24:06 25 4
gpt4 key购买 nike

我想将 mpld3 图的宽度和高度设置为特定值(以像素为单位,以便适合它所在的 div)。我尝试的方式看起来像这样 (javascript):

commands["width"]=plotWidth;
commands["height"]=plotHeight;
mpld3.draw_figure("plotname",commands);

plotWidth 和 plotHeight 我希望将高度和宽度设置为的值。

现在,这实际上将 mpld3-figure 对象的大小设置为我想要的值,但里面的绘图仍保持其旧大小,因此看起来什么也没发生。那么,如何更改绘图本身的大小?到目前为止,无论我做什么,情节都没有改变。

最佳答案

在使用 python 代码 plt.figure(figsize=(width,height)) 创建图形时,您可以更改 mpld3 图的形状(其中 widthheight 以英寸为单位)。这是一个 notebook demonstrating this .

已经有some interest in making mpld3 figures "responsive" ,这将是实现您的目标的一种更酷、更精确的方法,但到目前为止,还没有人尝试进行必要的代码更改。欢迎补丁!

关于matplotlib - 设置 mpld3 图的高度和宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31831130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com