【问题标题】:Set the height and width of a mpld3 plot设置 mpld3 绘图的高度和宽度
【发布时间】:2015-08-05 11:23:33
【问题描述】:

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

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

plotWidth 和 plotHeight 是我想要设置的高度和宽度的值。

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

【问题讨论】:

    标签: matplotlib mpld3


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2012-03-01
      • 2014-06-21
      • 1970-01-01
      • 2015-04-08
      • 2020-11-08
      • 2010-11-19
      • 1970-01-01
      • 2016-02-07
      • 2013-10-22
      相关资源
      最近更新 更多