Menu

Could you support LaTeX native?

Lu Niu
2019-07-01
2019-08-03
  • Lu Niu

    Lu Niu - 2019-07-01

    use "set term epslatex standalone" is very cumbersome and inefficient.
    Could you support for LaTeX natively in next version?

     

    Last edit: Lu Niu 2019-07-01
  • Ethan Merritt

    Ethan Merritt - 2019-07-01

    There are multiple LaTeX terminals already.
    My favorite is tikz, but you might find that another one suits your need better.
    What are your requirements?

     
    • Lu Niu

      Lu Niu - 2019-07-02

      Thanks a lot for your response.

      I often use set terminal cairolatex standalone to generate the tex file.
      and I have to compile it to get the graphic I want.

      I hope that Gnuplot can display LaTeX effect directly without that compilation process like its enhanced model.
      I suggest that you can make a function like mathtex(string) in GR.jl to determine what do I want to do with LaTeX. And realize LaTeX effects in Gnuplot GUI.

      Please forgive my weak English.

      Sincerely,

       

      Last edit: Lu Niu 2019-07-02
      • Ethan Merritt

        Ethan Merritt - 2019-07-02

        I am not familiar with julia, GR, and/or mathtex, but from searches online I gather that calling mathtex spawns a latex interpreter to produce a dvi or png file, which is then re-imported as an image. You could do that in gnuplot also but it is a lot more work than using the built-in enhanced text mode and it would probably produce worse results because you would lose the scalability of the font and associated vectors.

        Edit: confirmed in the source code at https://github.com/sciapp/gr/blob/master/lib/gr/gr.c
        gr.mathtex invokes latex2image.

        Can we go back to exactly what you need that you aren't finding? Is the issue that you want to use LaTeX macros like \gamma rather than typing the character 'γ'?

         

        Last edit: Ethan Merritt 2019-07-02
  • Lu Niu

    Lu Niu - 2019-07-03

    @sfeam

    Thanks a lot for your response,

    Matplotlib can also demonstrate LaTeX effect directly with plt.rc('text', usetex=True)(Details on https://matplotlib.org/users/usetex.html). I wish that Gnuplot can also use LaTeX macros and display LaTeX effect in its GUI directly.

    It is cumbersome for users to generate .tex file and compile it if they want LaTeX effect.

    Another suggestion is that could you make the Gnuplot package/extension vision for Python and Julia? Use Gnuplot in calculation program is more convenient than export data and load data to Gnuplot. Convience is also the reason for the success and popularity of Matplotlib. (I perfer the effect of Gnuplot)

    Sincerely,

     

    Last edit: Lu Niu 2019-07-03
    • Ethan Merritt

      Ethan Merritt - 2019-07-03

      PyGnuplot is available here
      https://pypi.org/project/PyGnuplot/
      I have not used Julia myself so I can make no recommendations, but two possibilities are
      https://github.com/mbaz/Gaston.jl
      https://github.com/gcalderone/Gnuplot.jl

      Mathplotlib invokes latex2png to produce an image. You could do the same thing from gnuplot, although there is no automated wrapper function for it. For example the following sequent of commands will display a TeX equation on your screen from inside a gnuplot session. I show the same TeX example as the mathplotlib documentation you linked.

      wrap(TeXstring) = '\begin{document} '.TeXstring.' \end{document}'
      title = '\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$'
      set print 'eq.tex'
      print wrap(title)
      unset print
      !latex2png eq
      !display eq.png
      

      Of course this requires previous installatio nof latex2png and ImageMagick (for the "display" command).

       
      • Lu Niu

        Lu Niu - 2019-07-03

        Thank you very very much!!!

        I am using Gastion.jl recently, the main issue is that its support for windows is not very good(Its author may have trouble on this issue, I hope that you can help this package).
        I sincerely hope that Gunplot can merge more features of modern programming language. because I found that my classmates and other young people rarely use Gnuplot, they tend to use more simple and convenient solutions, such as Matplotlib, PlotlyJS, GR, Plots.jl etc.. Although I perfer the effect of Gnuplot.

        Best wishes,

         

        Last edit: Lu Niu 2019-07-03
      • Lu Niu

        Lu Niu - 2019-08-03

        Your code cannot work with the error:

        LaTeX Error: File gnuplot-lua-tikz.sty' not found.
        

        I also think the "automated wrapper function" is more convenient.
        I hope that the next version can include it.

         
        • Ethan Merritt

          Ethan Merritt - 2019-08-03

          This is the latex style for for gnuplot. As with all latex packages, you must install it in your latex directory tree. If you build gnuplot yourself, the "make install" operation will install it along with the other support pieces. If you installed gnuplot from a package prepared elsewhere the *.sty file should have been included.

           
          • Lu Niu

            Lu Niu - 2019-08-03

            Thanks,

            I have successfully run your code just now with gnuplot-lua-tikz.sty.
            But I still think support latex like matplotlib is more flexible and convenient.

            For example, we can use Gaston.jl in Jupyter. However, if i want the effect of LaTeX, Jupyter cannot display it:

            Gaston in Jupyter

            Sincerely,

             

            Last edit: Lu Niu 2019-08-03

Log in to post a comment.