如何在不使用Matplotlib的情况下,在JupyterLab中画一条给定英寸数的线?

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

StackOverflow要求我键入这个,因为它希望我添加一些上下文来解释下面的代码部分。

def drawLine(inches):
    pass
python jupyter jupyter-lab
1个回答
0
投票

你可以用html5和html魔术这样的方法。

%%html

<canvas id="canvas" width="400" height="200"></canvas>  
<script>  
var canvas = document.getElementById('canvas');

if (canvas.getContext) 
 {
  //dots per inch
  dpi=96 
  var context = canvas.getContext('2d');
  context.beginPath(); 
  context.moveTo(0,10);
  context.lineTo(dpi,10);
  context.stroke();
   }
</script> 
© www.soinside.com 2019 - 2024. All rights reserved.