Take the 2-minute tour ×

I'm trying to convert a so called "dotplot" into latex. This plots are used in biology to compare sequences. Each axis represents a sequence and the coordinates of a dot are the actual X and Y position, similar to a plot without markers.

While the overall plot is quite easy, I'm struggling, again, with the axis. One axis (either X or Y) consist of several concatenated axis, .e.g. the X-axis harbors three sequences which have a total length of N whereby the length of each subsequence varies. What I want is to plot the axis for each subsequence (from 0 - end) on the X axis. Or simpler: How can I plot several small X-axis on one long X-Axis.

I saw that my MWE created some confusion. I attached a picture of an example I'd like to reproduce using pgfplot. The X-axis is one sole sequence while the Y-axis has two subsequences: one is indicated on the right and one on the left Y-axis. Both start with 0 and cover the length for each subsequence. The first sequence stops where the second begins.

As Jake pointed out, the nested loop should add the possibility to add the minor ticks. Also, there are only the first two subsequences in the MWE (out of 17). I have to mention that the MWE is not the data I show in the attached picture but it should indicate my problem
DotPlot with one subsequence on the X-axis and two subsequences on the Y-axis ---\UPDATE

I calculated the corresponding start and length for each subsequence:

       start   length
Seq0   0.00     47.81
Seq1   47.82    59.93
Seq2   107.76   49.29
Seq3   157.06   52.94

I tried nested loops. The outer for the beginning of each subsequence and the inner to plot the ticks:

  \foreach \start/\len  in {0/47.81, 47.82/59.93, 107.76/49.29} % subsequences
     \foreach \j  in {0,100,...,\len} %% the minor ticks of the subsequences

However, I did not succeed in replacing the ticks with this construct, either by placing it into x coord trafo/.code or drawing directly. The pgfmanual mentions different kinds of foreach loops, e.g. \pgfplotsforeachungrouped, but I do not understand how I can use them to plot selfmade axis.

I tried the approach as described in plot within a plot: zoom into a plot so that the magnified part is framed by axis with ticks and tick labels. This is the most promising approach until now, but I cannot get the two axis for the subsequences side -by-side and properly scaled. I have the suspicion it's something similar to my previous question Two different scales on stacked barplot, but I cannot figure it out.


\documentclass[11pt, a4paper]{article}
\usepackage[margin = 1cm]{geometry}
   [rotate = -90]%% the origin (0/0) of the original plot and pgfplots differ
        %%plotting dots
   enlargelimits = false,
   only marks,
   width = \linewidth,
   hide x axis,
   hide y axis,
coordinates {
(704 , 704)%% lower right corner
(704 , 698)
(704 , 691)
(704 , 47)
(703 , 703)
(703 , 698)
(702 , 702)
(702 , 655)
(702 , 337)
(702 , 53)
(702 , 52)
%% more coordinates here. removed for simplicity
(11 , 11)
(10 , 10)
(9 , 9)
(8 , 8)
(7 , 7)
(6 , 6)
(5 , 5)
(4 , 4)
(3 , 3)
(2 , 2)
(1 , 1)
(1 , 0)
(0 , 0)%%upper left corner
\node[anchor = east] at (0,0){\begin{axis}[%%<-- First subsequence
               xmin = 0, xmax = 47.81,
               ymin = 0, ymax = 1,
               scale only axis,
               hide y axis,
               axis x line* = bottom,
               enlargelimits = false,
  \node[anchor = east] at (47.82,0){\begin{axis}[%%<-- Second subsequence
               xmin = 0, xmax = 59.93,
               ymin = 0, ymax = 1,
               scale only axis,
               hide y axis,
               axis x line* = bottom,
               enlargelimits = false,

share|improve this question
Are there actually only four subsequences on your x axis? The lengths of the subsequences only add up to 210, but your coordinates go up to 704. Also, your \foreach snippet seems to suggest that you want tick marks placed 100 units apart, but all the subsequences are less than 100 units long. Maybe you could include an image of what you want the plot to look like? –  Jake Jun 14 '12 at 22:01
Sorry for the lag. I attached a picture and updated the description. There are actually two subsequences. The 100 in the nested loop is only an example sine 1 dot corresponds to several basepairs. –  LeJosh Jun 18 '12 at 14:50
@Jake you weren't notified by the comment above. (more than one year age :) ) - Lejosh, use @username notation to notify others of your comments. –  masu Oct 23 '13 at 12:05
add comment

Your Answer



Browse other questions tagged or ask your own question.