Skip to content

Adding gap style to gap.plot() #14

Description

@fdchevalier

Dear @dmurdoch,

When using the gap.plot() function, the gap style cannot be specified. When no box is drawn, the default gap is not very aesthetic. This can be fixed by adding an argument. Here is a patch:

--- gap.plot.R  2025-11-07 15:31:36.369932400 -0600
+++ gap.plot_style.R    2025-11-07 15:34:17.711783300 -0600
@@ -1,6 +1,6 @@
 # Try to rewrite this for an arbitrary number of gaps

-gap.plot<-function(x,y,gap,gap.axis="y",bgcol="white",breakcol="black",
+gap.plot<-function(x,y,gap,gap.axis="y",style="gap",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,...) {
@@ -111,10 +111,10 @@
     staxlab(2,at=show.at,labels=show.labels)
    }
    else axis(2,at=show.at,labels=show.labels)
-   axis.break(2,gap[1],style="gap",bgcol=bgcol,
+   axis.break(2,gap[1],style=style,bgcol=bgcol,
     breakcol=breakcol,brw=brw)
    if(length(gapsize) > 2) {
-    axis.break(2,gap[3]-gapsize[1],style="gap",bgcol=bgcol,
+    axis.break(2,gap[3]-gapsize[1],style=style,bgcol=bgcol,
      breakcol=breakcol,brw=brw)
     points(x[middleones],y[middleones]-gapsize[1],
      lty=lty[middleones],col=col[middleones],pch=pch[middleones],...)
@@ -145,9 +145,9 @@
     staxlab(1,at=show.at,labels=show.labels)
    }
    else axis(1,at=show.at,labels=show.labels)
-   axis.break(1,gap[1],style="gap")
+   axis.break(1,gap[1],style=style)
    if(length(gapsize) > 2) {
-    axis.break(1,gap[3]-gapsize[1],style="gap")
+    axis.break(1,gap[3]-gapsize[1],style=style)
     points(x[middleones]-gapsize[1],y[middleones],
      lty=lty[middleones],col=col[middleones],pch=pch[middleones],...)
     points(x[bigones]-(gapsize[1]+gapsize[3]),y[bigones],

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