0
$\begingroup$

I'm trying to "ArrayPlot" data generated from another code. I need to do it for different dimensions. Below a certain size everything works properly but from some value for the dimension it doesn't work anymore. The .txt files I import are constructed as follow.

1.234,2.567,8.987

4.567,9.543,6.567

4.890,78.56,76.87

as you can see it represents a n by n matrix. The code I use is the following

Husimi = Import["/Users/.../dataexample.txt", {"Data"}];


ArrayPlot[Husimi]

Everything is working fine for matrix up to the dimension n=288, The following case is n=544 and then it doesn't work anymore. The output is a thin vertical line. It seems to me that mathematica is treating my data as a unidimensional list taking every line of my file as a unique element. Any idea why ? I have the feeling that this case is very dumb but I am stuck.

Many thanks in advance

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica StackExchange! Try using AspectRatio option, for example: ArrayPlot[Husimi, AspectRatio -> 1]. If that doesn't solve your problem, there might be something wrong with your data (so please also post the screenshot). $\endgroup$
    – Domen
    Commented Aug 6, 2023 at 19:09
  • $\begingroup$ Please post the link about the n=544 data file. $\endgroup$
    – cvgmt
    Commented Aug 6, 2023 at 23:04

1 Answer 1

0
$\begingroup$

First, delete the empty lines, they will result in empty rows.

Then either store the file with an extension "csv" (comma separated values). Then everything will work:

d = Import["d:/tmp/dat.csv"]
ArrayPlot[d]

{{1.234, 2.567, 8.987}, {4.567, 9.543, 6.567}, {4.89, 78.56, 76.87}}

enter image description here

However, if you insists of using a file extension of "txt", you must specify the format explicitly:

d = Import["d:/tmp/dat.txt", "CSV"]
$\endgroup$
1
  • $\begingroup$ Many thank, Changing Data to CSV in code works fine. $\endgroup$
    – ESch
    Commented Aug 7, 2023 at 11:36

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.