I'm computing an integral using two different quasirandom methods. (These correspond to the choice of parameters $\alpha_0= 0,\frac{1}{2}$ in the answer of Martin Roberts to How can one generate an open-ended sequence of low-discrepancy points in 3D? .) I have two corresponding lists that record the current estimates after $n, 2n, 3n,...$ iterations ($n=5,000,000$).

I can use ListPlot on the two lists, showing how they presumably converge to the value of the integral. Since I'm using different computational platforms, the current lengths of the lists are not necessarily exactly the same. I can, of course, use ListPlot by truncating the longer list to the length of the shorter one.

But, is there any sensible manner, in which I can jointly display the two lists in their current form, even if they are of different lengths, and thus convey better the (presently unknown) value to which convergence appears to be occurring (a matter of central concern, see https://quantumcomputing.stackexchange.com/questions/2740/estimate-determine-bures-separability-probabilities-making-use-of-corresponding), while still showing--in the same figure--the behavior of the two methodologies (a matter also of interest)?

As a note of further possible interest, in implementing the quasirandom sequences I'm using the remarkable code of Henrik Schumacher that greatly accelerates the InverseCDF command for normal distributions Can I use Compile to speed up InverseCDF? .

  • 1
    $\begingroup$ Whats wrong with just using ListPlot[{list1, list2}]? $\endgroup$
    – Carl Woll
    Commented Sep 19, 2018 at 23:12
  • $\begingroup$ Re Carl Wall comment--ListPlot[{list1, list2}] does, in fact, work with different lengths (no error message), but I seem to have a subsidiary problem now with the use of DataRange, with each point corresponding to five million iterations. Using DataRange seems to result in the longer list being truncated to the length of the shorter one. I may, therefore, have to omit DataRange, and add additional explanatory information in the associated figure caption. $\endgroup$ Commented Sep 20, 2018 at 0:06
  • $\begingroup$ Some sample lists that exhibit your issue would be useful. $\endgroup$
    – Carl Woll
    Commented Sep 20, 2018 at 0:14
  • $\begingroup$ Well, if I use ListPlot[{list1, list2}] without including DataRange->{5,5 l_2}, where l_2 is the longer length, I do get the unequal lengths being shown (the object of my question), and I simply have to now label my $x$-axis as "5 million pts.", rather than "million pts." Thanks Carl Woll for asking me to do the obvious--I just assumed ListPlot would balk with unequal lengths. $\endgroup$ Commented Sep 20, 2018 at 0:25

1 Answer 1


ListPlot can handle multiple lists with different lengths. For example:

ListPlot[{Range[10], Sqrt[Range[5]]}]

enter image description here

If you want the data "stretched" so that they cover the same range, you can use DataRange:

ListPlot[{Range[10], Sqrt[Range[5]]}, DataRange->{0, 1}]

enter image description here

Note that the above stretching only happens when both lists are simple vectors of numbers.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.