Ilya Zakharevich on Sat, 14 Mar 1998 08:19:28 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Minor plotting improvements |
This increases vertical resolution of plot() 3.1 times, horizontal 10% and makes the plotting area into a square one (66 x 66), so that linear functions are perfect on the display (at least those which intersect y=0). The difference with the previous patch is that the vertical resolution of y=0 is improved as well, without this graphs with one of the boundaries being y=0 looked silly. Enjoy, Ilya Here are the samples: was: ? plot(x=-1,2,sin(x)) 1.000 |--------------------------------------------xxxxxxxxxxxx--| | xxxx xxx | xxxx | | xx | | xxx | | xx | | xx | | xx | | xx | | x | | xx | -------------------xx--------------------------------------- | xx | | xx | | xx | | xx | | xx | | xx | | xx | | xxx | -0.841 xx---------------------------------------------------------| -1.000 2.000 ? Now: ? plot(x=-1,2,sin(x)) 1.000 |'''''''''''''''''''''''''''''''''''''''''''''''__xxx~~~~~~~xxx_'| | _x~~ ~~ | _x~ | | _x~ | | _~ | | x~ | | x~ | | x~ | | x~ | | x~ | | _~ | ,,,,,,,,,,,,,,,,,,,,,,_~,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, | _~ | | _x | | _x | | x | | x~ | | _x~ | | _x | | _~ | | _x~ | -0.841 _x~..............................................................| -1.000 2.000 ? --- ../../src/graph/plotport.c~ Sat Feb 7 11:12:08 1998 +++ ../../src/graph/plotport.c Sat Mar 14 02:09:52 1998 @@ -36,20 +36,27 @@ PARI_plot pari_plot, pari_psplot; /** **/ /********************************************************************/ -#define ISCR 60 -#define JSCR 21 +#define ISCR 66 +#define JSCR 22 #define BLANK ' ' -#define ZERO '-' +#define ZERO1 ',' +#define ZERO2 '-' +#define ZERO3 '`' +#define PICTZERO(j) ((j) % 3 ? ((j) % 3 == 2 ? ZERO3 : ZERO2) : ZERO1) #define YY '|' -#define XX '-' -#define FF 'x' +#define XX_UPPER '\'' +#define XX_LOWER '.' +#define FF1 '_' +#define FF2 'x' +#define FF3 '~' +#define PICT(j) ((j) % 3 ? ((j) % 3 == 2 ? FF3 : FF2) : FF1) void plot(entree *ep, GEN a, GEN b, char *ch) { long av = avma, av2,limite,jz,j,i,sig; GEN p1,p2,ysml,ybig,x,diff,dyj,dx,y[ISCR+1]; - char scr[ISCR+1][JSCR+1]; + char scr[ISCR+1][JSCR+1], z; sig=gcmp(b,a); if (!sig) return; if (sig<0) { x=a; a=b; b=x; } @@ -61,7 +68,8 @@ plot(entree *ep, GEN a, GEN b, char *ch) for (j=1; j<=JSCR; j++) scr[1][j]=scr[ISCR][j]=YY; for (i=2; i<ISCR; i++) { - scr[i][1]=scr[i][JSCR]=XX; + scr[i][1] = XX_LOWER; + scr[i][JSCR]=XX_UPPER; for (j=2; j<JSCR; j++) scr[i][j]=BLANK; } av2=avma; limite=(av2+bot)>>1; @@ -81,12 +89,14 @@ plot(entree *ep, GEN a, GEN b, char *ch) } avma=av2; diff=gsub(ybig,ysml); if (gcmp0(diff)) { ybig=gaddsg(1,ybig); diff=gun; } - dyj=gdivsg(JSCR-1,diff); jz=1-gtolong(gmul(ysml,dyj)); + dyj=gdivsg((JSCR-1)*3+2,diff); jz=3-gtolong(gmul(ysml,dyj)); av2=avma; + z = PICTZERO(jz); jz = jz/3; for (i=1; i<=ISCR; i++) { - scr[i][jz]=ZERO; j=1+gtolong(gmul(gsub(y[i],ysml),dyj)); - scr[i][j]=FF; avma=av2; + scr[i][jz]=z; j=3+gtolong(gmul(gsub(y[i],ysml),dyj)); + scr[i][j/3] = PICT(j); + avma=av2; } p1=cgetr(4); gaffect(ybig,p1); pariputc('\n'); pariputsf(" %10.3f ",rtodbl(p1)); @@ -104,7 +114,7 @@ plot(entree *ep, GEN a, GEN b, char *ch) pariputc('\n'); p1=cgetr(4); p2=cgetr(4); gaffect(a,p1); gaffect(b,p2); pariputsf("%8s %10.3f %44s %10.3f\n"," ",rtodbl(p1)," ",rtodbl(p2)); - pariputc('\n'); pop_val(ep); avma=av; + pop_val(ep); avma=av; } /********************************************************************/