omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Tex Rendering via matplotlib/Tex

    Pythonista
    4
    7
    4837
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • nvedwards
      nvedwards last edited by

      Hello there!

      I am trying to create images of various mathematical equations so that I can include them in a document that I am working on. Using the code below, I have been successful rendering every type of equation that I have tried except a matrix equations.

      The LaTex markup that I used to generate the matrix is:

      r'$begin{Bmatrix} 1 & 2 \\ 3 & 4 \end{Bmatrix}$'

      Does Pythonista support rendering matrix equations? If so, how is it done?

      Thanks for the help!!

      Code:

      
      #import matplotlib.pyplot as plt
      from matplotlib import rc
      
      df_fig_sz = [1, 1]
      formulas = [[r'$\alpha > \beta$', df_fig_sz, 0.2, 0.25, 'alpha beta'], 
      [r'$\alpha_i > \beta_i$', df_fig_sz, 0.2, .25, 'ss_script'], 
      [r'$\sqrt{2}$', df_fig_sz, 0.2, .25, 'radicals_01'], 
      [r'$\sqrt[3]{x}$', df_fig_sz, 0.2, .25, 'radicals_02']
       ]
      for f in formulas:
      	params = {'figure.figsize': f[1],}
      	plt.rcParams.update(params)
      	fig = plt.figure()
      	fig.text(f[2], f[3], f[0])
      	plt.savefig(f[4] + '.png')
      
      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        If your Python code will be properly formatted and syntax highlighted if this forum if you surround it with:<br>
        <br>
        <blank line><br>
        ```python<br>
        # your code goes here...<br>
        ```

        1 Reply Last reply Reply Quote 0
        • nvedwards
          nvedwards last edited by

          ccc,
          I assume that you mean that I should format my code according to the example you provided. I did and now my code appears to have no structure. Please clarify. Thanks.

          1 Reply Last reply Reply Quote 0
          • omz
            omz last edited by

            @nvedwards You have to use backticks, not single quotes (I've already fixed it for you).

            1 Reply Last reply Reply Quote 0
            • nvedwards
              nvedwards last edited by

              Thanks omz. This is my first time posting so I appreciate the help. btw, I love both Pythonista and Editoria. Great Apps!!!

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                Unless you specify usetex, you are only using the matplotlib mathtext, not latex.
                See. http://matplotlib.org/users/mathtext.html#mathtext-tutorial
                I'm pretty sure pythonista doesn't have an external latex package included, so you can't use usetex.

                1 Reply Last reply Reply Quote 0
                • nvedwards
                  nvedwards last edited by

                  Thanks much JonB!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors