Skip to content

Commit e2f9706

Browse files
committed
Iniciado suporte ao box plot. ainda nao finalizado
1 parent 4c4882c commit e2f9706

File tree

2 files changed

+41
-98
lines changed

2 files changed

+41
-98
lines changed

src/main.cc

+24-13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ int main()
1010

1111
Matrix matrix_x = Matrix(200,1);
1212
Matrix matrix_y = Matrix(200,1);
13+
1314
//Inicialização teste;
1415
for (int i=1; i <= 200; i++)
1516
{
@@ -21,29 +22,39 @@ int main()
2122

2223
matrix_y.add(i, 1, sin(2*xCoord) + cos(xCoord));
2324
matrix_y.add(i, 2, cos(2*xCoord) + sin(xCoord)); //Segundo plotter em Y. Alterando dados
24-
matrix_y.add(i, 3, 1);
25+
matrix_y.add(i, 3, xCoord*0.05);
2526
}
2627

2728
//Instanciando plotter
29+
2830
//MatrixPlot matrixplot = MatrixPlot(2, 2); //Define subplot Cols; subplot Rows;
31+
MatrixPlot matrixplot1 = MatrixPlot();
32+
matrixplot1.setAutoRange(false);
2933

30-
MatrixPlot matrixplot = MatrixPlot();
31-
matrixplot.setAutoRange(false);
34+
matrixplot1.SetRange('x', -10, 10);
35+
matrixplot1.SetRange('y', -2, 2);
3236

33-
matrixplot.SetRange('x', -10, 10);
34-
matrixplot.SetRange('y', -2, 6);
37+
matrixplot1.plot1d(matrix_x, matrix_y);
38+
matrixplot1.saveToFile("teste.eps");
3539

36-
matrixplot.plot1d(matrix_x, matrix_y);
37-
cout << "Depois do plot" << endl;
40+
matrixplot1.Run();
3841

39-
matrixplot.saveToFile("teste.eps");
4042

41-
matrixplot.Run();
43+
//Exemplo usando matrix plot
4244

43-
return 0;
44-
}
45+
//Inicializacao do boxplot - Ainda em implementacao
46+
/*
47+
Matrix matrixbox = Matrix(2,4);
48+
for (int i=1; i <= matrixbox.getRows(); i++)
49+
for (int j=1; j <= matrixbox.getCols(); j++)
50+
matrixbox.add(i,j, j*8);
51+
52+
MatrixPlot matrixplot = MatrixPlot();
53+
matrixplot.plotbox(matrixbox);
4554
46-
void testSimulation()
47-
{
4855
56+
matrixplot.Run();
57+
*/
58+
59+
return 0;
4960
}

src/matrix-plot.cc

+17-85
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919

2020
#include "matrix-plot.h"
21-
#include "MatrixPlotWindow.h"
2221

2322
MatrixPlot::MatrixPlot(int subplotCols, int subplotRows)
2423
{
@@ -176,15 +175,6 @@ void MatrixPlot::plot1d(Matrix & xMatrix, Matrix & yMatrix){
176175

177176
this->SetOrigin(0,0,0);
178177

179-
//Subplotagem
180-
181-
/*this->SubPlot(
182-
this->subplotCols,
183-
this->subplotRows,
184-
0, "");
185-
186-
this->Axis("xy");*/
187-
188178
string color = "";
189179
switch (subplotIndex)
190180
{
@@ -197,6 +187,9 @@ void MatrixPlot::plot1d(Matrix & xMatrix, Matrix & yMatrix){
197187
case 2:
198188
color = "b";
199189
break;
190+
case 3:
191+
color = "w";
192+
break;
200193
}
201194

202195
if (this->autoRange && subplotIndex == (subplotAmount-1))
@@ -216,88 +209,27 @@ void MatrixPlot::plot1d(Matrix & xMatrix, Matrix & yMatrix){
216209

217210
void MatrixPlot::plotbox(Matrix & referenceMatrix, int subplotIndex)
218211
{
219-
int matrixRows = referenceMatrix.getRows();
220-
int matrixCols = referenceMatrix.getCols();
221-
222-
mglData matrix_X_coordinates(matrixRows);
223-
mglData matrix_Y_coordinates(matrixRows);
224-
225-
range matrixRange;
226-
227-
float matrixData[matrixRows][matrixCols];
228-
229-
for (int i=0; i < matrixRows; i++)
230-
{
212+
int matrixPlotRows = referenceMatrix.getRows();
213+
int subplotAmount = referenceMatrix.getCols();
231214

232-
for (int j=0; j < matrixCols; j++)
233-
{
234-
float dataPoint = referenceMatrix.getMat(i+1,j+1);
235-
236-
if (j == 0)
237-
{
238-
239-
//Min_x
240-
try {
241-
if (dataPoint < matrixRange.x_min)
242-
matrixRange.x_min = dataPoint;
243-
} catch (...) {
244-
matrixRange.x_min = dataPoint;
245-
}
246-
247-
//Max_x
248-
try {
249-
if (dataPoint > matrixRange.x_max)
250-
matrixRange.x_max = dataPoint;
251-
} catch (...) {
252-
matrixRange.x_max = dataPoint;
253-
}
254-
255-
256-
matrix_X_coordinates.a[i] = dataPoint;
257-
}
258-
else
259-
{
260-
//Min_x
261-
try {
262-
if (dataPoint < matrixRange.y_min)
263-
matrixRange.y_min = dataPoint;
264-
} catch (...) {
265-
matrixRange.y_min = dataPoint;
266-
}
215+
mglData dataBox(subplotAmount);
267216

268-
//Max_x
269-
try {
270-
if (dataPoint > matrixRange.y_max)
271-
matrixRange.y_max = dataPoint;
272-
} catch (...) {
273-
matrixRange.y_max = dataPoint;
274-
}
275-
276-
matrix_Y_coordinates.a[i] = dataPoint;
277-
}
278-
279-
}
280-
281-
}
282-
283-
this->SetOrigin(0,0,0);
284-
285-
//Subplotagem
286-
287-
this->SubPlot(
288-
this->subplotCols,
289-
this->subplotRows,
290-
subplotIndex, "");
217+
range matrixRange;
291218

292-
this->Axis("xy");
219+
for (int subplotIndex=0; subplotIndex < subplotAmount; subplotIndex++)
220+
{
221+
mglData dataItem(matrixPlotRows);
293222

294-
if (this->autoRange)
223+
for (int matrixPlotRowIndex=0; matrixPlotRowIndex < matrixPlotRows; matrixPlotRowIndex++)
295224
{
296-
this->SetRange('x', matrixRange.x_min, matrixRange.x_max);
297-
this->SetRange('y', matrixRange.y_min, matrixRange.y_max);
225+
float x = referenceMatrix.getMat((matrixPlotRowIndex+1), (subplotIndex+1));
226+
dataItem.a[matrixPlotRowIndex] = x;
227+
//dataBox.Set(&x, (long int)matrixPlotRowIndex, (long int)subplotIndex);
298228
}
229+
}
299230

300-
this->Plot(matrix_X_coordinates, matrix_Y_coordinates);
231+
this->Box();
232+
this->BoxPlot(dataBox);
301233

302234
}
303235

0 commit comments

Comments
 (0)