QCustomPlot how to resize chart?

3

I'm trying to do a repeating histogram of 255 events, I do not know how many times this event can occur!

I have an array of 255 elements, already with the amount of repetitions of the events and I want to show this in the graph using QCustomPlot , but the size that is < > 4.8, 4.8 , and my histogram hits 23079 or more, maybe much more.

How do you increase this 4.8, 4.8 and leave the chart well away?

Here's part of the code:

int grayScale[255] = {0};

//faco meus bang pra montar o array
QVector<double> x(255),y(255);
ui->customPlot->addGraph();
for(int i = 0; i < 255; i++)
{
    x[i] = i;
    y[i] = grayScale[i];
}
ui->customPlot->graph(0)->setData(x, y);
ui->customPlot->xAxis->setLabel("Tom");
ui->customPlot->yAxis->setLabel("Quantidade");
ui->customPlot->replot();

I'm waiting and thank you right away!

    
asked by anonymous 25.05.2015 / 20:23

1 answer

2

Normally the scale of the graph should be determined automatically so that all values are visible. Apparently, in your case, this is not happening.

You can force a scale using the setRange(int x, int y) method. In your case you can try:

int grayScale[255] = {0};

//faco meus bang pra montar o array
QVector<double> x(255),y(255);
ui->customPlot->addGraph();
for(int i = 0; i < 255; i++)
{
    x[i] = i;
    y[i] = grayScale[i];
}
ui->customPlot->graph(0)->setData(x, y);
ui->customPlot->xAxis->setLabel("Tom");
ui->customPlot->yAxis->setLabel("Quantidade");

ui->customPlot->xAxis->setRange(0, 255); 
ui->customPlot->yAxis->setRange(0, 23079); // aqui deves alterar para o valor máximo no teu universo, por exemplo, guardando o valor numa variável 'ui->customPlot->yAxis->setRange(0, maxGrayScale);' 

ui->customPlot->replot();
    
26.05.2015 / 11:30