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$
  • $\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 '15 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$ – Karsten 7. Mar 17 '15 at 0:33
  • $\begingroup$ @rcollyer I'm using Mathematica 10.0.2 $\endgroup$ – Lea Mar 17 '15 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 '15 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 '15 at 8:22
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$
  • 1
    $\begingroup$ On can use elp // InputForm to see if elp contains any string. $\endgroup$ – Karsten 7. Mar 17 '15 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 '15 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$ – Karsten 7. Mar 19 '15 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$
  • $\begingroup$ No, that is not the point. $\endgroup$ – Lea Mar 16 '15 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 '15 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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