       for i of means
         means[i] /= n[i]
 
-      pxgXaxis.selectAll("empty")
-              .data(means)
-              .enter()
-              .append("line")
-              .attr("class", "PXGvert")
-              .attr("y1", top[2])
-              .attr("y2", bottom[2])
-              .attr("x1", (d,i) -> return if(chr is "X") then pxgXscaleX(i) else pxgXscaleA(i))
-              .attr("x2", (d,i) -> return if(chr is "X") then pxgXscaleX(i) else pxgXscaleA(i))
-              .attr("stroke", darkGray)
-              .attr("fill", "none")
-              .attr("stroke-width", "1")
-      pxgXaxis.selectAll("empty")
-              .data(genotypes)
-              .enter()
-              .append("text")
-              .attr("class", "PXGgeno")
-              .text((d) -> d)
-              .attr("y", bottom[2] + pad.bottom*0.25)
-              .attr("x",  (d,i) -> return if(chr is "X") then pxgXscaleX(i) else pxgXscaleA(i))
-              .attr("fill", labelcolor)
-      pxgXaxis.selectAll("empty")
-              .data(["Female", "Male"])
-              .enter()
-              .append("text")
-              .attr("class", "PXGsex")
-              .attr("id", "sextext")
-              .text((d) -> d)
-              .attr("y", bottom[j] + pad.bottom*0.75)
-              .attr("x", (d, i) -> sexcenter[i])
-              .attr("fill", labelcolor)
+      draw_pxgXaxis(pxgXaxis, means, genotypes, chr, sexcenter)
 
       svg.append("g").attr("id", "plotPXG").attr("class", "probe_data").attr("id","PXGpoints").selectAll("empty")
           .data(probe_data.pheno)

      for i of means
        means[i] /= n[i]

      console.log(means)
#      svg.selectAll("line.PXGvert").transition().data(means).exit().remove()
#      svg.selectAll("line.PXGmeans").transition().data(means).exit().remove()
#      svg.selectAll("text.PXGgeno").transition().data(means)
#      svg.selectAll("text.PXGsex").transition().attr("x", (d,i) -> sexcenter[i]).exit().remove()

      svg.selectAll("circle.plotPXG")
         .transition().duration(1000)
         .attr("cx", (d,i) -> 
              g = Math.abs(data.geno[marker][i])
              sx = data.sex[i]

                 .domain(d3.range(4))
                 .rangePoints([left[2], right[2]], 1)

  # create SVG
  svg = d3.select("div#cistrans").append("svg")
          .attr("width", totalw)
          .attr("height", totalh)
