Graphics, Figures & TablesPSTricks | Other than linear Fitting

Information and discussion about graphics, figures & tables in LaTeX documents.
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTricks | Other than linear Fitting

Post by CrazyHorse »

svend_tveskaeg wrote:
CrazyHorse wrote:don't know why it is not on CTAN.
tlmgr tells me that it is now!
yes, I uploaded it for Buddy Ledger, the author of the package. You should directly write to him for.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: PSTricks | Other than linear Fitting

Post by svend_tveskaeg »

@Herbert:
I have send a request e-mail to the author. I will post the relevant parts of his respone here when (if) I get one, and if he allows me to do so.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

PSTricks | Other than linear Fitting

Post by svend_tveskaeg »

From the author:

It has been a while since I looked at this code. Let me try to answer your questions.

First I do plan to work on this package in the future but I can't promise it will happen quickly.

With respect to your two technical questions:

1. (math mode): everything that I have written is in postscript all the LaTeX is pstricks original aside from some key values used to pass parameters to postscript. Unfortunately that communication is one way LaTeX -> Postscript. The fitted equation is determined in postscript and is not known (nor can it be passed to) LaTeX. Therefore, we can't use LaTeX mathmode to print the equation. However, you could adjust the postscript code to format the equation differently and maybe even approximate math mode appearance.

2. (order of coefficients): the order of the coefficients in the printed equation is as you have stated a0 + a1*x^1 + a2*x^2 + ... +an*x^n. This is achieved in the following code block, starting at line 805:

Code: Select all

  PolyEq { (y =) show
  1 1 m { /ci exch def
          ai ci 1 sub get 30 string cvs show
          ci 1 sub 0 gt { xPr } if
          ci 1 sub 1 gt {%
             0 \psk@fontscale 4 div rmoveto ci 1 sub 30 string cvs show
             0 \psk@fontscale 4 div neg rmoveto } if 
          ci m eq not { ai ci get 0 lt {}{ (+) show } ifelse } if
  } for } if 

to reverse the print order simply changethe for loop so that it loops backward (m -1 1)

Code: Select all

  PolyEq { (y =) show
  m -1 1 { /ci exch def
          ai ci 1 sub get 30 string cvs show
          ci 1 sub 0 gt { xPr } if
          ci 1 sub 1 gt {%
             0 \psk@fontscale 4 div rmoveto ci 1 sub 30 string cvs show
             0 \psk@fontscale 4 div neg rmoveto } if 
          ci 1 eq not { ai ci get 0 lt {}{ (+) show } ifelse } if
  } for } if
I hope that helps.

Check out this example on the pstricks page if you want equations labeled in mathmode. I wrote this quick hack of gnuplottex which may accomplish what you want in terms of appearance. Note that gnuplot uses non-linear curve fitting and convergence is not gauranteed. http://tug.org/PSTricks/main.cgi?file=G ... ot#fitting
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply