2
$\begingroup$

I have the following list

list

and try to plot it in an ErrorListPlot. The result of

ErrorListPlot[elp, 
PlotRange -> {{0.9, 3.2}, {0, 35}}, Frame -> True, Axes -> False]

is an empty plot:

empty

With the direct usage of the values in the plot command:

ErrorListPlot[{{30., 5.2/Sqrt[462]}, {29.3, 3.9/Sqrt[4]},
{27.2, 8.2/Sqrt[80]}}, 
PlotRange -> {{0.9, 3.2}, {0, 35}}, Frame -> True, Axes -> False]

I get the awaited result:

works

Can anybody give me a hint, why it does not work with the list? In my application, the list is much longer and it would be very inconvenient to write the list directly into the command.

$\endgroup$
5
  • $\begingroup$ what version of Mathematica are you using? I've checked on v9.0.2 and 8.0.1 and I can't reproduce this. $\endgroup$
    – rcollyer
    Mar 16, 2015 at 13:20
  • $\begingroup$ Does elp == {{30., 5.2/Sqrt[462]}, {29.3, 3.9/Sqrt[4]}, {27.2, 8.2/Sqrt[80]}} return True? $\endgroup$
    – Karsten7
    Mar 17, 2015 at 0:33
  • $\begingroup$ @rcollyer I'm using Mathematica 10.0.2 $\endgroup$
    – Lea
    Mar 17, 2015 at 8:16
  • $\begingroup$ @Karsten7. No, strangely enough not. It gives {{30., 5.2/Sqrt["462"]}, {29.3, 3.9/Sqrt["4"]}, {27.2, 8.2/Sqrt[ "80"]}} == {{30., 0.241926}, {29.3, 1.95}, {27.2, 0.916788}} $\endgroup$
    – Lea
    Mar 17, 2015 at 8:17
  • $\begingroup$ If I'm using a step in between with test = {{30., 5.2/Sqrt[462]}, {29.3, 3.9/Sqrt[4]}, {27.2, 8.2/Sqrt[80]}} and then ErrorListPlot[test, PlotRange -> {{0.9, 3.2}, {0, 35}}, Frame -> True, Axes -> False] it works. $\endgroup$
    – Lea
    Mar 17, 2015 at 8:22

2 Answers 2

1
$\begingroup$

You can find the reason why the plot is empty in one of your comments.

{{30., 5.2/Sqrt["462"]}, {29.3, 3.9/Sqrt["4"]}, {27.2, 8.2/Sqrt["80"]}}

The arguments for the Sqrt functions are stings of numbers, not numbers.
You can convert these strings to numbers using ToExpression:

elp = elp /. s_String :> ToExpression[s]

Now

ErrorListPlot[elp, PlotRange -> {{0.9, 3.2}, {0, 35}}, Frame -> True, Axes -> False]

should return the expected plot.

$\endgroup$
3
  • 1
    $\begingroup$ On can use elp // InputForm to see if elp contains any string. $\endgroup$
    – Karsten7
    Mar 17, 2015 at 15:12
  • $\begingroup$ Okay thank you very much, with the knowledge, that the Sqrt uses strings I can completely understand the problem. Do I find such information in the documentation? $\endgroup$
    – Lea
    Mar 19, 2015 at 12:31
  • $\begingroup$ @Lea If the argument for Sqrt is a string, it'll not evaluate to a numerical value. Try Sqrt[4], Sqrt["4"], and Sqrt["test"]. This is part of the "everything can be represented as symbolic expression" Wolfram Language programming paradigm. $\endgroup$
    – Karsten7
    Mar 19, 2015 at 17:22
0
$\begingroup$

I guess it is because of the square symbol. Try

ErrorListPlot[elp//N ,PlotRange -> {{0.9, 3.2}, {0, 35}}, Frame -> True, Axes -> False]
$\endgroup$
2
  • $\begingroup$ No, that is not the point. $\endgroup$
    – Lea
    Mar 16, 2015 at 12:32
  • $\begingroup$ Sorry, maybe I was wrong and it could help, but elp//N does not work in my case $\endgroup$
    – Lea
    Mar 17, 2015 at 10:15

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.