Home > Mobile >  How to use the correlation function of qcpcolormap will data in a text file map into color
How to use the correlation function of qcpcolormap will data in a text file map into color

Time:10-12

I have a 0001. TXT file, in the first column is the x axis, the coordinates of the second column is the y coordinate, the third column is the size of the corresponding point of the electric field value, want to ask how great god with the related functions take the qcpcolormap TXT file data in the map into color? Equivalent to each value of the coordinates of the electric field with different colors to represent the
TXT file content is roughly the following this format (can't upload attachments, so manual typing)
3 3 12
2, 3, 7.5
1 3 4.3
3 2 15
2, 2, 2.3
1 2, 3.6
3 1 14
2, 1, 8.5
1, 1, 5.2

CodePudding user response:

The elder brothers still let me answer you, I have done similar


The core code below
 QString fileName=QString (" :/file/data % 1. TXT "). Arg (qrand () % 3); 
QFile file (fileName);
If (file. Open (QFile: : ReadOnly | QIODevice: : Text)) {
QString data=https://bbs.csdn.net/topics/QLatin1String (file. ReadAll ());
file.close();

QVector Keys and values;
QStringList list=data. The split (" ");
Int len=list. The length ();

//if it is not a multiple of the length to 2 minus 1
If (len % 2!=0) {
Len=(len - 1);
}

for (int i=0; i Keys. Append (I);
}

//every two hexadecimal digits combined into a digital
for (int i=0; i Qint16 value=https://bbs.csdn.net/topics/API::strHexToShort (QString (" % 1% 2 "). Arg (list) at (I)). Arg (list) at (I + 1)));
Values. Append (value);
}

The UI - & gt; CustomPlot9 - & gt; SetDataLine (0, "Angle value", keys, values, true);
The UI - & gt; CustomPlot9 - & gt; Replot ();
}

CodePudding user response:

reference 1st floor feiyangqingyun response:
elder brothers still let me answer you, I have done similar


The core code below
 QString fileName=QString (" :/file/data % 1. TXT "). Arg (qrand () % 3); 
QFile file (fileName);
If (file. Open (QFile: : ReadOnly | QIODevice: : Text)) {
QString data=https://bbs.csdn.net/topics/QLatin1String (file. ReadAll ());
file.close();

QVector Keys and values;
QStringList list=data. The split (" ");
Int len=list. The length ();

//if it is not a multiple of the length to 2 minus 1
If (len % 2!=0) {
Len=(len - 1);
}

for (int i=0; i Keys. Append (I);
}

//every two hexadecimal digits combined into a digital
for (int i=0; i Qint16 value=https://bbs.csdn.net/topics/API::strHexToShort (QString (" % 1% 2 "). Arg (list) at (I)). Arg (list) at (I + 1)));
Values. Append (value);
}

The UI - & gt; CustomPlot9 - & gt; SetDataLine (0, "Angle value", keys, values, true);
The UI - & gt; CustomPlot9 - & gt; Replot ();
}

Great god: hello, can you explain this code general train of thought, why should every two hexadecimal digits combined into one number, and setdataline function is what meaning, feeling finally can only draw a function curve

CodePudding user response:

reference 1st floor feiyangqingyun response:
elder brothers still let me answer you, I have done similar


The core code below
 QString fileName=QString (" :/file/data % 1. TXT "). Arg (qrand () % 3); 
QFile file (fileName);
If (file. Open (QFile: : ReadOnly | QIODevice: : Text)) {
QString data=https://bbs.csdn.net/topics/QLatin1String (file. ReadAll ());
file.close();

QVector Keys and values;
QStringList list=data. The split (" ");
Int len=list. The length ();

//if it is not a multiple of the length to 2 minus 1
If (len % 2!=0) {
Len=(len - 1);
}

for (int i=0; i Keys. Append (I);
}

//every two hexadecimal digits combined into a digital
for (int i=0; i Qint16 value=https://bbs.csdn.net/topics/API::strHexToShort (QString (" % 1% 2 "). Arg (list) at (I)). Arg (list) at (I + 1)));
Values. Append (value);
}

The UI - & gt; CustomPlot9 - & gt; SetDataLine (0, "Angle value", keys, values, true);
The UI - & gt; CustomPlot9 - & gt; Replot ();
}

Great god: hello, can you explain this code general train of thought, why should every two hexadecimal digits combined into one number, and setdataline function is what meaning, feeling finally can only draw a function curve

CodePudding user response:

reference 1st floor feiyangqingyun response:
elder brothers still let me answer you, I have done similar


The core code below
 QString fileName=QString (" :/file/data % 1. TXT "). Arg (qrand () % 3); 
QFile file (fileName);
If (file. Open (QFile: : ReadOnly | QIODevice: : Text)) {
QString data=https://bbs.csdn.net/topics/QLatin1String (file. ReadAll ());
file.close();

QVector Keys and values;
QStringList list=data. The split (" ");
Int len=list. The length ();

//if it is not a multiple of the length to 2 minus 1
If (len % 2!=0) {
Len=(len - 1);
}

for (int i=0; i
  •  Tags:  
  • Qt
  • Related