The R Project SVN R

Rev

Rev 7133 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7133 Rev 7192
Line 771... Line 771...
771
    /* Determine the tick mark positions.  Note that these may fall */
771
    /* Determine the tick mark positions.  Note that these may fall */
772
    /* outside the plot window. We will clip them in the code below. */
772
    /* outside the plot window. We will clip them in the code below. */
773
 
773
 
774
    if (length(at) == 0) {
774
    if (length(at) == 0) {
775
	PROTECT(at = CreateAtVector(axp, usr, nint, logflag));
775
	PROTECT(at = CreateAtVector(axp, usr, nint, logflag));
776
	n = length(at);
-
 
777
    }
776
    }
778
    else {
777
    else {
779
	if (isReal(at)) PROTECT(at = duplicate(at));
778
	if (isReal(at)) PROTECT(at = duplicate(at));
780
	else PROTECT(at = coerceVector(at, REALSXP));
779
	else PROTECT(at = coerceVector(at, REALSXP));
781
	n = length(at);
-
 
782
    }
780
    }
-
 
781
    n = length(at);
783
 
782
 
784
    if (dolabels) {
783
    if (dolabels) {
785
	if (length(lab) == 0)
784
	if (length(lab) == 0)
786
	    lab = labelformat(at);
785
	    lab = labelformat(at);
787
	else if (!isExpression(lab))
786
	else if (!isExpression(lab))
Line 888... Line 887...
888
		}
887
		}
889
	    }
888
	    }
890
	}
889
	}
891
	dd->gp.col = dd->gp.colaxis;
890
	dd->gp.col = dd->gp.colaxis;
892
	/* labels */
891
	/* labels */
-
 
892
	gap = GStrWidth("m", NFC, dd);	/* FIXUP x/y distance */
893
	tlast = -1.0;
893
	tlast = -1.0;
894
	if (dd->gp.las == 2 || dd->gp.las == 3) {
894
	if (dd->gp.las == 2 || dd->gp.las == 3) {
895
	    if (side == 1) dd->gp.adj = 1;
895
	    if (side == 1) dd->gp.adj = 1;
896
	    else dd->gp.adj = 0;
896
	    else dd->gp.adj = 0;
897
	}
897
	}
898
	else dd->gp.adj = 0.5;
898
	else dd->gp.adj = 0.5;
899
 
899
 
900
	gap = GStrWidth("m", NFC, dd);	/* FIXUP x/y distance */
-
 
901
	for (i = 0; i < n; i++) {
900
	for (i = 0; i < n; i++) {
902
	    x = REAL(at)[i];
901
	    x = REAL(at)[i];
903
	    tempx = x; tempy = y;
902
	    tempx = x; tempy = y;
904
	    GConvert(&tempx, &tempy, USER, NFC, dd);
903
	    GConvert(&tempx, &tempy, USER, NFC, dd);
905
	    if (dolabels) {
904
	    if (dolabels) {
Line 908... Line 907...
908
			       dd->gp.mgp[1], 0, x, dd->gp.las, dd);
907
			       dd->gp.mgp[1], 0, x, dd->gp.las, dd);
909
		}
908
		}
910
		else {
909
		else {
911
		    labw = GStrWidth(CHAR(STRING(lab)[ind[i]]), NFC, dd);
910
		    labw = GStrWidth(CHAR(STRING(lab)[ind[i]]), NFC, dd);
912
		    tnew = tempx - 0.5 * labw;
911
		    tnew = tempx - 0.5 * labw;
913
		    /* Check that there is space */
-
 
914
		    /* for  perpendicular labels. */
912
		    /* Check room for perpendicular labels: */
915
		    if (dd->gp.las == 2 || dd->gp.las == 3 ||
913
		    if (dd->gp.las == 2 || dd->gp.las == 3 ||
916
			tnew - tlast >= gap) {
914
			tnew - tlast >= gap) {
917
			GMtext(CHAR(STRING(lab)[ind[i]]), side,
915
			GMtext(CHAR(STRING(lab)[ind[i]]), side,
918
			       dd->gp.mgp[1], 0, x,
916
			       dd->gp.mgp[1], 0, x,
919
			       dd->gp.las, dd);
917
			       dd->gp.las, dd);
Line 968... Line 966...
968
		    GLine(x0, y, x1, y, USER, dd);
966
		    GLine(x0, y, x1, y, USER, dd);
969
		}
967
		}
970
	    }
968
	    }
971
	}
969
	}
972
	else {
970
	else {
-
 
971
	    /* The R(ight) way of doing ticks (using "tcl", not "tck") */
973
	    for (i = 0; i < n; i++) {
972
	    for (i = 0; i < n; i++) {
974
		y = REAL(at)[i];
973
		y = REAL(at)[i];
975
		if (low <= y && y <= high) {
974
		if (low <= y && y <= high) {
976
		    GLine(y, 0, y, -dd->gp.tcl, ytckCoords, dd);
975
		    GLine(y, 0, y, -dd->gp.tcl, ytckCoords, dd);
977
		}
976
		}
978
	    }
977
	    }
979
	}
978
	}
980
	dd->gp.col = dd->gp.colaxis;
979
	dd->gp.col = dd->gp.colaxis;
-
 
980
	/* labels */
981
	gap = GStrWidth("m", INCHES, dd);
981
	gap = GStrWidth("m", INCHES, dd);
982
	gap = GConvertYUnits(gap, INCHES, NFC, dd);
982
	gap = GConvertYUnits(gap, INCHES, NFC, dd);
983
	tlast = -1.0;
983
	tlast = -1.0;
984
	if (dd->gp.las == 1 || dd->gp.las == 2) {
984
	if (dd->gp.las == 1 || dd->gp.las == 2) {
985
	    if (side == 2) dd->gp.adj = 1;
985
	    if (side == 2) dd->gp.adj = 1;
986
	    else dd->gp.adj = 0;
986
	    else dd->gp.adj = 0;
987
	}
987
	}
988
	else dd->gp.adj = 0.5;
988
	else dd->gp.adj = 0.5;
-
 
989
 
989
	for (i = 0; i < n; i++) {
990
	for (i = 0; i < n; i++) {
990
	    y = REAL(at)[i];
991
	    y = REAL(at)[i];
991
	    tempx = x; tempy = y;
992
	    tempx = x; tempy = y;
992
	    GConvert(&tempx, &tempy, USER, NFC, dd);
993
	    GConvert(&tempx, &tempy, USER, NFC, dd);
993
	    if (dolabels) {
994
	    if (dolabels) {
Line 997... Line 998...
997
		}
998
		}
998
		else {
999
		else {
999
		    labw = GStrWidth(CHAR(STRING(lab)[ind[i]]), INCHES, dd);
1000
		    labw = GStrWidth(CHAR(STRING(lab)[ind[i]]), INCHES, dd);
1000
		    labw = GConvertYUnits(labw, INCHES, NFC, dd);
1001
		    labw = GConvertYUnits(labw, INCHES, NFC, dd);
1001
		    tnew = tempy - 0.5 * labw;
1002
		    tnew = tempy - 0.5 * labw;
1002
		    /* Check room for  perpendicular labels: */
1003
		    /* Check room for perpendicular labels: */
1003
		    if (dd->gp.las == 1 || dd->gp.las == 2 ||
1004
		    if (dd->gp.las == 1 || dd->gp.las == 2 ||
1004
			tnew - tlast >= gap) {
1005
			tnew - tlast >= gap) {
1005
			GMtext(CHAR(STRING(lab)[ind[i]]), side,
1006
			GMtext(CHAR(STRING(lab)[ind[i]]), side,
1006
			       dd->gp.mgp[1], 0, y,
1007
			       dd->gp.mgp[1], 0, y,
1007
			       dd->gp.las, dd);
1008
			       dd->gp.las, dd);
Line 1009... Line 1010...
1009
		    }
1010
		    }
1010
		}
1011
		}
1011
	    }
1012
	    }
1012
	}
1013
	}
1013
	break;
1014
	break;
1014
    }
1015
    } /* end  switch(side, ..) */
1015
 
1016
 
1016
    GMode(0, dd);
1017
    GMode(0, dd);
1017
    GRestorePars(dd);
1018
    GRestorePars(dd);
1018
    /* NOTE: only record operation if no "error"  */
1019
    /* NOTE: only record operation if no "error"  */
1019
    /* NOTE: during replay, call == R_NilValue */
1020
    /* NOTE: during replay, call == R_NilValue */