2
$\begingroup$

I am using Mathematica 10.0.1 on Windows 64-bit machine.

I have two 1D lists as follows.

list1 = {0.544677,0.43988,0.23622,0.240472,0.208341,2.70294,1.25687,0.208341};
list2 = {0.407358,0.352106,0.195608,0.329957,0.205924,2.35814,1.28687,0.205924};

I would like to use ListPlot to see their correlation and have the same ticks on both the axis. I use the Ticks option in-built in Mathematica, and later also try the CustomTicks.mpackage. Following are the pieces of codes using both methods.

maxTick = Max[list1,list2];

ListPlot[Transpose[{list1,list2}], Ticks-> { Range[0,maxTicks,0.5], Range[0,maxTicks,0.5]}, PlotRange->All, AspectRatio->1]
ListPlot[Transpose[{list1,list2}], Ticks-> {LinTicks[0,maxTick], LinTicks[0,maxTick]}, PlotRange->All, AspectRatio->1]

Using both methods I do not get the same number of ticks on both the axes. On x-axis the ticks are shown up to a value of 2.7, but on the y-axis they are shown only up to 2.4, whereas I would like to have the ticks shown up to a value of 2.7. Somehow the ticks are limited to the maximum value of the corresponding lists and rounded off for which the tick is shown, i.e. 2.70294 for list1 on the axis is rounded to 2.7, and 2.35814 is rounded to 2.4 for list2. I have also tried using some of the options in the LinTicks from the CustomTicks.m package, such as TicksRange and ExtraTicks. However nothing seems to plot the ticks up to 2.7 on both axes.

Perhaps I am missing something obvious. Could someone please help me getting the same tick marks on both axes? I encountered the same problem for version 10.0.0 too.

Thanks!

P.S: I tried pasting the images here but could not. So please excuse me if my problem is a bit difficult to understand.

$\endgroup$

2 Answers 2

2
$\begingroup$

With

list1 = {0.544677, 0.43988, 0.23622, 0.240472, 0.208341, 2.70294, 1.25687, 0.208341};
list2 = {0.407358, 0.352106, 0.195608, 0.329957, 0.205924, 2.35814, 1.28687, 0.205924};
maxTicks = Max[list1, list2];

you can get the desired plot using

ListPlot[Transpose[{list1, list2}], Ticks -> {#, #} &@Range[0, maxTicks, 0.5], 
  PlotRange -> {#, #} &@{0, maxTicks + 0.1}, AspectRatio -> 1]

Plot

You need to provide the same maximum values for both axes instead of PlotRange->All.

$\endgroup$
1
$\begingroup$

Same tick marks on both axes:

ListPlot[Transpose[{list1, list2}],
 PlotRange -> {{0, 3}, {0, 3}},
 PlotTheme -> "Detailed"]

enter image description here

$\endgroup$

Your Answer

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

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