设置 mpld3 图的高度和宽度
Set the height and width of a mpld3 plot
我想将 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
图的形状(其中 width
和 height
在英寸)。这里有一个notebook demonstrating this.
已经有 some interest in making mpld3
figures "responsive",这将是实现您的目标的一种更酷、更精确的方法,但到目前为止还没有人尝试进行必要的代码更改。欢迎补丁!
我想将 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
图的形状(其中 width
和 height
在英寸)。这里有一个notebook demonstrating this.
已经有 some interest in making mpld3
figures "responsive",这将是实现您的目标的一种更酷、更精确的方法,但到目前为止还没有人尝试进行必要的代码更改。欢迎补丁!