| Ilya Zakharevich on Thu, 8 Oct 1998 20:30:02 -0400 (EDT) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Plotting patch |
This patch for plot() is two-fold.
First, it changes the char-to-plot-high from '*' (which is in the
middle for many fonts) to '"' (which I hope is up with most fonts).
Second, it adds intermediate points if the points for two consequent
values of i are far-separeted.
Now the result of plot(x=2,4,sin(x^3)) looks like this:
9.997e-01"''''''''''''"'''''''''"'''''''"''''''"'''''"''''''''''''''"'''|
|_ x : : : : : "
|: " : : x : _ :: : "" "_ : :
| : : : " : : : : : : : :: :: : :
| x : : : : _ : : _ : : :: :: : :
| : : x : : : : " : : x :: :: : : :
| : _ : : : : : : : _ : :: :: : : :
| : : : : : : : : : : : :: :: : : :
| x : : : _ : : : : : : : : : : : : :|
| : : : _ : : : : : : : : : : : x x :|
,,,:,,,,,,:,,,,,:,,,,:,,,:,,,:,,,:,,:,,,:,,:,:,,:,,:,:,,:,:,:,:,
| : : _ : : : x : : : : : : : : : : :|
| : " : : : : : : : : : : : : : : : :|
| " : : : : x : : : : : x _ : : : : :|
| : : : : : : : _ : : : : : x : : : x|
| : : : : : : : : " : : : : : :: ::|
| : : : _ _ : : : : : : : : : ": ::|
| x x _ : : : : : : x ": :: :: ::|
| : : : : : : :: :: :: : :: : |
| : : :: :: x: : : : : : |
| x _ :: :" : : : : : : |
-9.998e-01|......_..........x".......x.......x....._....._...._...."...x.|
2.000e+00 4.000e+00
I hope you consider this as an improvement wrt the random mesh the
previous code would generate on the right.
9.997e-01*''''''''''''*'''''''''*'''''''*''''''*'''''*''''''''''''''*'''|
|_ x *
| * x _ ** *_ |
| * |
| x _ _ |
| x * x |
| _ _ |
| |
| x _ |
| _ x x |
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
| _ x |
| * |
| * x x _ |
| _ x x|
| * |
| _ _ * |
| x x _ x * |
| |
| x |
| x _ * |
-9.998e-01|......_..........x*.......x.......x....._....._...._....*...x.|
2.000e+00 4.000e+00
Enjoy,
Ilya
--- ./pari-2.0.11.beta/src/graph/plotport.c~ Thu Oct 8 02:10:20 1998
+++ ./pari-2.0.11.beta/src/graph/plotport.c Thu Oct 8 20:00:58 1998
@@ -47,7 +47,7 @@ PARI_plot pari_plot, pari_psplot;
#define XX_LOWER '.'
#define FF1 '_'
#define FF2 'x'
-#define FF3 '*'
+#define FF3 '"'
#define PICT(j) ((j) % 3 ? ((j) % 3 == 2 ? FF3 : FF2) : FF1)
void
--- ./pari-2.0.11.beta/src/graph/plotport.c~ Thu Oct 8 02:10:20 1998
+++ ./pari-2.0.11.beta/src/graph/plotport.c Thu Oct 8 20:18:49 1998
@@ -47,7 +47,7 @@ PARI_plot pari_plot, pari_psplot;
#define XX_LOWER '.'
#define FF1 '_'
#define FF2 'x'
-#define FF3 '*'
+#define FF3 '"'
#define PICT(j) ((j) % 3 ? ((j) % 3 == 2 ? FF3 : FF2) : FF1)
void
@@ -55,7 +55,7 @@ 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], z;
+ char scr[ISCR+1][JSCR+1], z, jprev, jnew;
sig=gcmp(b,a); if (!sig) return;
if (sig<0) { x=a; a=b; b=x; }
@@ -94,7 +94,36 @@ plot(entree *ep, GEN a, GEN b, char *ch)
for (i=1; i<=ISCR; i++)
{
scr[i][jz]=z; j=3+gtolong(gmul(gsub(y[i],ysml),dyj));
- scr[i][j/3] = PICT(j); avma=av2;
+ jnew = j/3;
+ if (i > 1) {
+ int i_up, i_down, mid = (jprev + jnew)/2, up, down;
+ int domid = 0, jmid;
+
+ /* If the gap is 1, leave it as it is. */
+ if (jprev < jnew - 2) {
+ i_up = i;
+ i_down = i - 1;
+ up = jnew - 1;
+ down = jprev + 1;
+ domid = 1;
+ } else if (jnew < jprev - 2) {
+ i_up = i - 1;
+ i_down = i;
+ down = jnew + 1;
+ up = jprev - 1;
+ domid = 1;
+ }
+ if (domid) {
+ while (down <= mid) {
+ scr[i_down][down++] = ':';
+ }
+ while (up > mid) {
+ scr[i_up][up--] = ':';
+ }
+ }
+ }
+ scr[i][jnew] = PICT(j); avma=av2;
+ jprev = jnew;
}
p1=cgetr(3); gaffect(ybig,p1); pariputc('\n');
pariputsf(" %8.3e",rtodbl(p1));