Message Boards Message Boards

0
|
3675 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

ListPlot a list of numbers in string format?

Hi,

What is the problem in using ListPlot command?

In[6]:= S1 = {"66.4", "2.8", "61.5", "504.4", "155.5", "155.5", "", 
  "", "", "", "", "", "", "", ""}

Out[6]= {"66.4", "2.8", "61.5", "504.4", "155.5", "155.5", "", "", \
"", "", "", "", "", "", ""}

In[7]:= S11 = DeleteCases[S1 /. "" -> x, x]

Out[7]= {"66.4", "2.8", "61.5", "504.4", "155.5", "155.5"}

In[8]:= ListPlot[S11]

enter image description here

POSTED BY: M.A. Ghorbani
2 Replies
Posted 5 years ago

Try this:

ListPlot[ToExpression@S11]
POSTED BY: Hans Milton
Posted 5 years ago

To add to the comment by Hans, the issue is that you're trying to use ListPlot on strings of real numbers, not real numbers themselves.

To get around this, Hans suggests using ToExpression to convert your strings of real numbers into proper numbers that ListPlot can work with.

In[10]:= ToExpression["12.2"]
Out[10]= 12.2
POSTED BY: Kyle Martin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract