| Ilya Zakharevich on Sat, 14 Mar 1998 07:38:45 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Minor plotting improvements |
This increases vertical resolution of plot() 3 times, horizontal
10% and makes the plotting area into a square one (66 x 66), so that linear
functions are perfect on the display.
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 01:27:06 1998
@@ -36,13 +36,17 @@ PARI_plot pari_plot, pari_psplot;
/** **/
/********************************************************************/
-#define ISCR 60
-#define JSCR 21
+#define ISCR 66
+#define JSCR 22
#define BLANK ' '
#define ZERO '-'
#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)
@@ -61,7 +65,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 +86,13 @@ 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=1-gtolong(gmul(ysml,dyj))/3;
av2=avma;
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]=ZERO; 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 +110,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;
}
/********************************************************************/