Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have two sets of data, list1 and list2. The ranges of data are different from each other.

list1= {{1, 2}, {2, 4}, {3, 8}, {4, 10}, {5, 12}, {6, 14}, {7, 16}, {8, 18}, {9, 20}}

list2= {{3, 8}, {4, 10}, {5, 12}, {6, 14}}

I tried this

ListPlot[{list1, list2}]

What happens with this is, because of the difference in the ranges of data, Mathematica seems to adjust the ranges of the x axis and y axis to fit both the curves on on plot(which makes sense).

With the individual lists, I did this

ListLinePlot[list1, PlotRange -> {{0, 10}, {0, 6}]

But when I tried this for both the lists together,

ListPlot[{list1, list2}, PlotRange -> {{0, 6}, {0, 8}]

It plots only one list. The second one in this case.

What I want to do is to plot them both on the same plot,and be able to control the range of x-axis and y-axis. I am interested seeing the behavior in the range between 0 and 6 in the x-axis and 0 and 8 in the y.

Not sure how to proceed.

share|improve this question
    
I do not understand. Why not use PlotRange->All? like this: data1 = Table[{i, RandomReal[1]}, {i, 20}]; data2 = Table[{i, RandomReal[1]}, {i, 10}]; ListPlot[{data1, data2}, Joined -> True, PlotRange -> All] this gives this: !Mathematica graphics isn't this what you want? it will always be best to given a MWE showing the problem, else one have to guess what you mean. –  Nasser Aug 27 '13 at 11:14
    
@Nasser- Thanks. What you said works. But I still cant manipulate the axes. I want to study the behavior of both the curves in a particular range. –  NutCase Aug 27 '13 at 11:45
1  
if you post a minumum working example, so one can understand what you mean. make up some data and show the problem. a picture is worth 1,000 words ;) –  Nasser Aug 27 '13 at 11:46
    
@Nasser I have a plot. But I cant upload the image. :/ Anything else I can do? –  NutCase Aug 27 '13 at 11:50
    
Just post the code you used to make the plot. I assume it is a small example, self contained hopefully. –  Nasser Aug 27 '13 at 11:51
show 5 more comments

closed as off-topic by Yves Klett, Artes, halirutan, Sjoerd C. de Vries, rm -rf Aug 27 '13 at 22:38

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Yves Klett, Sjoerd C. de Vries, rm -rf
  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Artes, halirutan
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

For future reference, to minimize the ambiguity of your question, it would be very helpful to post a representative data set (it doesn't have to be the whole thing). Short of that however, I have made two data sets that have a large difference in range between one another:

list1 = Range[10];
list2 = Range[10]*100;

To answer the question you asked, you can manipulate the independent and dependent variable ranges like so:

Manipulate[
ListPlot[{list1, list2}, 
PlotRange -> {{xmin, xmax}, {ymin, ymax}}], {ymin, 0, 100}, {ymax, 
20, 1000}, {xmin, 0, 5}, {xmax, 10, 20}]

enter image description here

where you choose appropriate min/max ranges for your data set. However, something that may be more helpful that takes away the need to modify your ranges to begin with is to use a log-scale (ListLogPlot gives the dependent variable a log-scale):

ListLogPlot[{list1, list2}]

enter image description here

Using a log-scale allows you to see the details that would normally be swallowed by the range of the graph. Similarly, if you needed a log-scale for both independent and dependent values (or if you wanted to maintain the linear look of the data), there is:

ListLogLogPlot[{list1, list2}]

enter image description here

If you need a log-scale for only independent variables, use:

ListLogLinearPlot[{list1, list2}]

All of the details regarding these functions can be found in the Mathematica Documentation

share|improve this answer
add comment

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