我可以在 Google colab 平台上制作的 ipywidget 下拉菜单中使用乳胶吗

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

我正在尝试使用乳胶方程式进行下拉

ipywidget
。我想显示一些希腊符号(如 theta),但我做不到

我用

matplotlib
来代替
polarplots
,之前,我用
sintax r'$\latex$
'来编译传统图上的符号,然而,这里不起作用。

我的代码

import ipywidgets as widgets
import numpy as np
import matplotlib.pyplot as plt

def cardioide_widget(a=4,cardioide=1):
  
  fig = plt.figure(figsize=(5,5))
  axp = plt.subplot(111, projection="polar")


  # Definición de variables para gráficas
  def c(cardioide,theta):
    if cardioide == 1: 
      return a+a*np.cos(theta)
    elif cardioide == 2: 
      return a-a*np.cos(theta)
    elif cardioide == 3: 
      return a+a*np.sin(theta)
    elif cardioide == 4: 
      return a-a*np.sin(theta)

  theta = np.linspace(0, 2*np.pi, 200)

  #Gráfica en coordenadas polares
  axp.plot(theta,c(cardioide,theta))
  
  #Límites para los ejes polares
  axp.set_rmax(10.05)
   


  plt.show()


widgets.interact(cardioide_widget, a=(0.5,5.0,0.1),cardioide=[(r'$r = a + a cos(\theta)$',1),('r = a - a cos(theta)',2),('r = a + a sen(theta)',3),('r = a - a sen(theta)',4)]);

我只是在尝试下拉菜单中的第一个词

menú

(r'$r = a + a cos(\theta)$',1)

python python-3.x latex google-colaboratory
© www.soinside.com 2019 - 2024. All rights reserved.