Skip to content

gap.plot() ignores axis parameters #13

Description

@fdchevalier

Dear @dmurdoch,

When using the gap.plot() function, the axis parameters (xaxt, yaxt) are ignored. These are needed if a user wants to remove an axis (especially when no box is drawn). This can be fixed by adding *axt to the relevant axis() lines. Here is a patch:

--- gap.plot.R  2025-11-07 15:31:36.369932400 -0600
+++ gap.plot_axes.R     2025-11-11 17:43:05.521557500 -0600
@@ -3,7 +3,7 @@
 gap.plot<-function(x,y,gap,gap.axis="y",bgcol="white",breakcol="black",
  brw=0.02,xlim=range(x),ylim=range(y),xticlab,xtics=NA,yticlab,ytics=NA,
  lty=rep(1,length(x)),col=rep(par("col"),length(x)),pch=rep(1,length(x)),
- add=FALSE,stax=FALSE,...) {
+ add=FALSE,stax=FALSE,yaxt=par("yaxt"),xaxt=par("xaxt"),...) {

  if(missing(y) && !missing(x)) {
   y<-x
@@ -92,7 +92,7 @@
    lty=lty[littleones],col=col[littleones],pch=pch[littleones],...)
   box()
   if(gap.axis == "y") {
-   if(!is.na(xtics[1])) axis(1,at=xtics,labels=xticlab)
+   if(!is.na(xtics[1])) axis(1,at=xtics,labels=xticlab,xaxt=xaxt)
    littletics<-which(ytics < gap[1])
    if(length(gapsize) > 2) {
     middletics<-which(ytics >= gap[2]+ygw & ytics <= gap[3])
@@ -126,7 +126,7 @@
   }
   # x gaps need to be fixed
   else {
-   if(!is.na(ytics[1])) axis(2,at=ytics,labels=yticlab)
+   if(!is.na(ytics[1])) axis(2,at=ytics,labels=yticlab,yaxt=yaxt)
    littletics<-which(xtics < gap[1])
    if(length(gapsize) > 2) {
     middletics<-which(xtics >= gap[2] + xgw & xtics <= gap[3])

Happy to submit a pull request if it is useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions