go-hep.org/x/hep@v0.38.1/hplot/htex/handler_example_test.go (about)

     1  // Copyright ©2020 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package htex_test
     6  
     7  import (
     8  	"fmt"
     9  	"log"
    10  
    11  	"go-hep.org/x/hep/hplot"
    12  	"go-hep.org/x/hep/hplot/htex"
    13  )
    14  
    15  func ExampleGoHandler() {
    16  	hdlr := htex.NewGoHandler(-1, "pdflatex")
    17  
    18  	for i := range 10 {
    19  		name := fmt.Sprintf("plot-%0d", i)
    20  		p := hplot.New()
    21  		p.Title.Text = name
    22  		p.X.Label.Text = "x"
    23  		p.Y.Label.Text = "y"
    24  
    25  		err := hplot.Save(
    26  			hplot.Figure(p, hplot.WithLatexHandler(hdlr)),
    27  			-1, -1, name+".tex",
    28  		)
    29  		if err != nil {
    30  			log.Fatalf("could not save plot: %+v", err)
    31  		}
    32  	}
    33  
    34  	err := hdlr.Wait()
    35  	if err != nil {
    36  		log.Fatalf("error compiling latex: %+v", err)
    37  	}
    38  }