I am trying to do something I assumed would be simple, but I'm hitting a roadblock and I don't know why. I have the following table:

Kerr = Table[{s[[i]]/m[[i]]^2, m[[i]]}, {i, 1, Length[m]}]

Where s and m are one-dimensional arrays of the same length, imported from data files. I'm combining them into the table named Kerr, and I want to plot that (with s/m^2 on the x axis and m on the y axis. The table looks like this: Table

When I try to do ListPlot[Kerr], the axes come back empty. I assume I'm doing something fundamentally wrong, but I've no idea what. Any ideas?

  • 1
    $\begingroup$ try Kerr = Table[Flatten@{s[[i]]/m[[i]]^2, m[[i]]}, {i, 1, Length[m]}]; ListPlot[Kerr]? $\endgroup$
    – kglr
    Oct 5, 2019 at 11:04

1 Answer 1


Note, that every number in your Kerr list is bracketed with { }. ListPlot expects a list of the form: {{1,1},{2,4},{3,9}}. So you just have to remove that innermost brackets which, I think, comes from lists s &m.

I am not sure how they are written in your data files. You can try to rewrite your function in the following way:

Kerr = Table[{(s[[i]]/m[[i]]^2)[[1]], m[[i]][[1]]}, {i, 1, Length[m]}]
  • $\begingroup$ That worked like a charm! Thanks a lot! $\endgroup$
    – Sotiris
    Oct 5, 2019 at 11:22

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.