0
$\begingroup$

So I've been trying to import a large set of data (6900 point pairs) from an excel (.xls) file. The Exel file has 2 columns of numeric data. I've also been trying to plot this data, but when I do, it won't allow me to alter my DataRange.

Here is a simplified version of my code:

Subscript[Elliptical\[ScriptCapitalL], \[Nu]] = 
 Import["EllipticalGalaxy.xls"][[3]]

ListPlot[Subscript[Elliptical\[ScriptCapitalL], \[Nu]], 
 DataRange -> {0, 10000}]

Actually, no matter which DataRange I specify, this will not alter the plot (i.e. the default way it is plotting doesn't even include all my points).

My fix for this was to use PlotRange, instead, which actually works, UNLESS I use ListLogLinearPlot (or ListLogLogPlot, or ListLogPlot).

Here is another sample of my code when I replace ListPlot with ListLogLinearPlot:

ListLogLinearPlot[Subscript[Elliptical\[ScriptCapitalL], \[Nu]], 
 PlotRange -> {{0, Log[10000]}, {0, 1}}]

This will alter the range of the plot, but not the domain...

My 2 questions are:

1) Why won't DataRange work?

2) Why won't PlotRange work for the logarithmic axis?

$\endgroup$
6
  • 1
    $\begingroup$ PlotRange and DataRange serve different purposes. The first is to control how much to plot, wheras the second is to relabel the x index. Reading up on both of these in the docs will make things clearer $\endgroup$
    – rm -rf
    Sep 30, 2012 at 5:29
  • $\begingroup$ I understand that, but I haven't been using them simultaneously. $\endgroup$
    – Atreyu
    Sep 30, 2012 at 5:32
  • $\begingroup$ There's nothing wrong with using them simultaneously. You should include a minimal example, because we don't have your xls file $\endgroup$
    – rm -rf
    Sep 30, 2012 at 5:34
  • $\begingroup$ ListLogLinearPlot[{{0, 1}, {1, 2}, {2, 3}, {3, 4}}, PlotRange -> {{0, Log[2]}, {0, 3.7}}] The x axis won't change its x values in this case... I'm clearly a beginner =P $\endgroup$
    – Atreyu
    Sep 30, 2012 at 5:41
  • $\begingroup$ Same for ListPlot[{{0, 1}, {1, 2}, {2, 3}, {3, 4}}, DataRange -> {0, 2}], the data range remains from 0 to 3, no matter which values I enter for DataRange $\endgroup$
    – Atreyu
    Sep 30, 2012 at 5:52

1 Answer 1

3
$\begingroup$

Your PlotRange starts at 0 on the log axis and that's preventing MMa from evaluating it. MMa is falling back to Automatic when you are using a 0 on a log scale. Use for example 0.5

ListLogLinearPlot[{{0, 1}, {1, 2}, {2, 3}, {3, 4}}, Joined -> True, 
 PlotRange -> {{0.5, Log[20]}, {0, 3.7}}]

or similar.

I don't know what your data looks like but if you got {x, y} data point pairs then DataRange makes no sense with ListPlot. DataRange is used when you only have y-values and want to set their x range. In 3D this is the same for ListContourPlot when you have {x, y} pairs you can set their range.

$\endgroup$
3
  • $\begingroup$ This still doesn't change anything for me... but thank you for the comment on DataRange. $\endgroup$
    – Atreyu
    Sep 30, 2012 at 7:05
  • $\begingroup$ Using Show gives the right plot range for me, but there's still a few quirks you need to work around, which I'm still unsure of... $\endgroup$
    – Atreyu
    Sep 30, 2012 at 8:02
  • 2
    $\begingroup$ @Atreyu Maybe it would help if you could provide some of your data points, say 10 to 20 so we can work with data you are using. What are the quirks? $\endgroup$
    – Matariki
    Sep 30, 2012 at 8:09

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.